-
Notifications
You must be signed in to change notification settings - Fork 222
Add functionality to notify systemd on olad startup and config reload #1444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
a30e440
a5e57fe
183ac8d
693fe33
0257949
50c9bda
29556d0
b7afd38
83807d4
469361d
f15b385
d674930
bf8deff
175b393
17d917c
1cd1202
64400b8
d62a8f6
ff34724
f6f5813
15efd6f
18735c4
a21f0a4
c714ee8
527b115
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,10 @@ | |
| #include <config.h> | ||
| #endif // HAVE_CONFIG_H | ||
|
|
||
| #ifdef HAVE_LIBSYSTEMD | ||
| #include <systemd/sd-daemon.h> | ||
| #endif // HAVE_LIBSYSTEMD | ||
|
|
||
| #include <errno.h> | ||
| #include <signal.h> | ||
| #include <stdio.h> | ||
|
|
@@ -472,9 +476,17 @@ bool OlaServer::InternalNewConnection( | |
| } | ||
|
|
||
| void OlaServer::ReloadPluginsInternal() { | ||
| #ifdef HAVE_LIBSYSTEMD | ||
| // Return value is intentionally not checked for both calls. | ||
| // See return value section under sd_notify(3). | ||
| sd_notify(0, "RELOADING=1\nSTATUS=Reloading plugins\n"); | ||
|
||
| #endif // HAVE_LIBSYSTEMD | ||
| OLA_INFO << "Reloading plugins"; | ||
| StopPlugins(); | ||
| m_plugin_manager->LoadAll(); | ||
| #ifdef HAVE_LIBSYSTEMD | ||
| sd_notify(0, "READY=1\nSTATUS=Plugin reload complete\n"); | ||
|
||
| #endif // HAVE_LIBSYSTEMD | ||
| } | ||
|
|
||
| void OlaServer::UpdatePidStore(const RootPidStore *pid_store) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,10 @@ | |
| #include <config.h> | ||
| #endif // HAVE_CONFIG_H | ||
|
|
||
| #if HAVE_LIBSYSTEMD | ||
| #include <systemd/sd-daemon.h> | ||
| #endif // HAVE_LIBSYSTEMD | ||
|
|
||
| #include <signal.h> | ||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
|
|
@@ -171,6 +175,11 @@ int main(int argc, char *argv[]) { | |
| ola::NewCallback(olad->GetOlaServer(), &ola::OlaServer::ReloadPlugins)); | ||
| #endif // _WIN32 | ||
|
|
||
| #if HAVE_LIBSYSTEMD | ||
| // Return value is intentionally not checked. See return value section | ||
| // under sd_notify(3). | ||
| sd_notify(0, "READY=1\nSTATUS=Startup complete\n"); | ||
|
||
| #endif // HAVE_LIBSYSTEMD | ||
| olad->Run(); | ||
| return ola::EXIT_OK; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you see have_libftd2xx above, you should really initialise it to no before you use it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem. I'll follow the examples from the above location.
What do you think about making linking against
libsystemda command line option to the build system? I'm thinking build systems that havelibsystemdmay silently cause built binaries to link againstlibsystemd, and this could lead to a bit of a dependency problem, unless they're aware of this new change.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it may make sense, see e.g. https://github.com/OpenLightingProject/ola/blob/master/configure.ac#L494-L518 .
I was wondering, but at least it's only libsystemd, it doesn't require systemd itself.