mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
cli: Add sd-notify integration
Let's make sysprof-cli send a READY=1 sd-notify message when it's finished its setup logic. This allows starting sysprof as a systemd service and delaying startup of other services until sysprof has finished its setup logic. This ensures we don't miss any profiling data when running sysprof-cli in a systemd service as part of the bootup process. We skip this step for now when we're running a child process so that we don't accidentally interfere with a child process that receives an sd-notify socket and is supposed to send notifications on it instead of sysprof-cli.
This commit is contained in:
committed by
Christian Hergert
parent
2b972a3ac6
commit
b2091926fe
@ -13,6 +13,10 @@ if polkit_agent_dep.found()
|
||||
sysprof_cli_deps += polkit_agent_dep
|
||||
endif
|
||||
|
||||
if libsystemd_dep.found()
|
||||
sysprof_cli_deps += libsystemd_dep
|
||||
endif
|
||||
|
||||
sysprof_cli = executable('sysprof-cli', sysprof_cli_sources,
|
||||
dependencies: sysprof_cli_deps,
|
||||
c_args: release_flags + sysprof_cli_c_args,
|
||||
|
||||
@ -38,6 +38,10 @@
|
||||
# include <polkitagent/polkitagent.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_LIBSYSTEMD
|
||||
# include <systemd/sd-daemon.h>
|
||||
#endif
|
||||
|
||||
#include "sysprof-capture-util-private.h"
|
||||
|
||||
#define DEFAULT_BUFFER_SIZE (1024L * 1024L * 8L /* 8mb */)
|
||||
@ -625,6 +629,11 @@ Examples:\n\
|
||||
|
||||
g_printerr ("Recording, press ^C to exit\n");
|
||||
|
||||
#if HAVE_LIBSYSTEMD
|
||||
if (command == NULL && child_argv == NULL)
|
||||
sd_notify (TRUE, "READY=1");
|
||||
#endif
|
||||
|
||||
g_main_loop_run (main_loop);
|
||||
|
||||
sysprof_capture_writer_flush (writer);
|
||||
|
||||
Reference in New Issue
Block a user