mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-11-10 06:51:54 +00:00
Improve systemd integration
When fluidsynth is run as a service using systemd, make sure the service is considered started only when it is ready to process events. In order to do so: - Add an optional runtime dependency to libsystemd to the fluidsynth executable - Change the systemd service type to "notify" - Have fluidsynth notify systemd that the service is started after the server is started - Have fluidsynth notify systemd that the service is stopping after joining the server thread
This commit is contained in:
parent
9671e412fe
commit
099369f8b7
6 changed files with 41 additions and 1 deletions
|
@ -80,6 +80,10 @@ if ( CMAKE_SYSTEM MATCHES "Linux|FreeBSD|DragonFly" )
|
|||
option ( enable-alsa "compile ALSA support (if it is available)" on )
|
||||
endif ( CMAKE_SYSTEM MATCHES "Linux|FreeBSD|DragonFly" )
|
||||
|
||||
if ( CMAKE_SYSTEM MATCHES "Linux" )
|
||||
option ( enable-systemd "compile systemd support (if it is available)" on )
|
||||
endif ( CMAKE_SYSTEM MATCHES "Linux" )
|
||||
|
||||
if ( CMAKE_SYSTEM MATCHES "Darwin" )
|
||||
option ( enable-coreaudio "compile CoreAudio support (if it is available)" on )
|
||||
option ( enable-coremidi "compile CoreMIDI support (if it is available)" on )
|
||||
|
@ -521,6 +525,14 @@ else(NOT enable-pkgconfig)
|
|||
remove_definitions( -DHAVE_LASH )
|
||||
endif ( enable-lash )
|
||||
|
||||
unset ( SYSTEMD_SUPPORT CACHE )
|
||||
if ( enable-systemd )
|
||||
pkg_check_modules ( SYSTEMD libsystemd )
|
||||
set ( SYSTEMD_SUPPORT ${SYSTEMD_FOUND} )
|
||||
else ( enable-systemd )
|
||||
unset_pkg_config ( SYSTEMD )
|
||||
endif ( enable-systemd )
|
||||
|
||||
unset ( DBUS_SUPPORT CACHE )
|
||||
if ( enable-dbus )
|
||||
pkg_check_modules ( DBUS dbus-1>=1.0.0 )
|
||||
|
|
|
@ -98,6 +98,12 @@ else ( LASH_SUPPORT )
|
|||
message ( "LASH support: no" )
|
||||
endif ( LASH_SUPPORT )
|
||||
|
||||
if ( SYSTEMD_SUPPORT )
|
||||
message ( "systemd support: yes" )
|
||||
else ( SYSTEMD_SUPPORT )
|
||||
message ( "systemd support: no" )
|
||||
endif ( SYSTEMD_SUPPORT )
|
||||
|
||||
if ( DART_SUPPORT )
|
||||
message ( "OS/2 DART support: yes" )
|
||||
else ( DART_SUPPORT )
|
||||
|
|
|
@ -4,6 +4,8 @@ Documentation=man:fluidsynth(1)
|
|||
After=sound.target
|
||||
|
||||
[Service]
|
||||
Type=notify
|
||||
NotifyAccess=main
|
||||
EnvironmentFile=@FLUID_DAEMON_ENV_FILE@
|
||||
EnvironmentFile=-%h/.config/fluidsynth
|
||||
ExecStart=@CMAKE_INSTALL_PREFIX@/@BIN_INSTALL_DIR@/fluidsynth -is $OTHER_OPTS $SOUND_FONT
|
||||
|
|
|
@ -95,6 +95,10 @@ if ( LASH_SUPPORT )
|
|||
include_directories ( ${LASH_INCLUDE_DIRS})
|
||||
endif ( LASH_SUPPORT )
|
||||
|
||||
if ( SYSTEMD_SUPPORT )
|
||||
include_directories ( ${SYSTEMD_INCLUDE_DIRS})
|
||||
endif ( SYSTEMD_SUPPORT )
|
||||
|
||||
if ( DART_SUPPORT )
|
||||
set ( fluid_dart_SOURCES drivers/fluid_dart.c )
|
||||
include_directories ( ${DART_INCLUDE_DIRS} )
|
||||
|
@ -341,6 +345,7 @@ endif ( FLUID_CPPFLAGS )
|
|||
|
||||
target_link_libraries ( fluidsynth
|
||||
libfluidsynth
|
||||
${SYSTEMD_LIBRARIES}
|
||||
${FLUID_LIBS}
|
||||
)
|
||||
|
||||
|
|
|
@ -49,6 +49,9 @@
|
|||
/* whether or not we are supporting lash */
|
||||
#cmakedefine HAVE_LASH @HAVE_LASH@
|
||||
|
||||
/* Define if systemd support is enabled */
|
||||
#cmakedefine SYSTEMD_SUPPORT @SYSTEMD_SUPPORT@
|
||||
|
||||
/* Define to 1 if you have the `MidiShare' library (-lMidiShare). */
|
||||
#cmakedefine HAVE_LIBMIDISHARE @HAVE_LIBMIDISHARE@
|
||||
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
|
||||
#include "fluid_lash.h"
|
||||
|
||||
#ifdef SYSTEMD_SUPPORT
|
||||
#include <systemd/sd-daemon.h>
|
||||
#endif
|
||||
|
||||
void print_usage(void);
|
||||
void print_help(fluid_settings_t *settings);
|
||||
|
@ -892,6 +895,12 @@ int main(int argc, char **argv)
|
|||
fprintf(stderr, "Failed to create the server.\n"
|
||||
"Continuing without it.\n");
|
||||
}
|
||||
#ifdef SYSTEMD_SUPPORT
|
||||
else
|
||||
{
|
||||
sd_notify(0, "READY=1");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -954,10 +963,13 @@ cleanup:
|
|||
fluid_server_join(server);
|
||||
}
|
||||
|
||||
#ifdef SYSTEMD_SUPPORT
|
||||
sd_notify(0, "STOPPING=1");
|
||||
#endif
|
||||
delete_fluid_server(server);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* NETWORK_SUPPORT */
|
||||
|
||||
if(cmd_handler != NULL)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue