[Core] Add systemd sd_notify support
This commit is contained in:
parent
9f0656a6ba
commit
d6de1d9af7
|
@ -248,7 +248,7 @@ endif
|
|||
lib_LTLIBRARIES = libfreeswitch.la
|
||||
libfreeswitch_la_CFLAGS = $(CORE_CFLAGS) $(SQLITE_CFLAGS) $(GUMBO_CFLAGS) $(FVAD_CFLAGS) $(FREETYPE_CFLAGS) $(CURL_CFLAGS) $(PCRE_CFLAGS) $(SPEEX_CFLAGS) $(LIBEDIT_CFLAGS) $(openssl_CFLAGS) $(SOFIA_SIP_CFLAGS) $(AM_CFLAGS) $(TPL_CFLAGS)
|
||||
libfreeswitch_la_LDFLAGS = -version-info 1:0:0 $(AM_LDFLAGS) $(PLATFORM_CORE_LDFLAGS) -no-undefined
|
||||
libfreeswitch_la_LIBADD = $(CORE_LIBS) $(APR_LIBS) $(SQLITE_LIBS) $(GUMBO_LIBS) $(FVAD_LIBS) $(FREETYPE_LIBS) $(CURL_LIBS) $(PCRE_LIBS) $(SPEEX_LIBS) $(LIBEDIT_LIBS) $(openssl_LIBS) $(PLATFORM_CORE_LIBS) $(TPL_LIBS) $(SPANDSP_LIBS) $(SOFIA_SIP_LIBS)
|
||||
libfreeswitch_la_LIBADD = $(CORE_LIBS) $(APR_LIBS) $(SQLITE_LIBS) $(GUMBO_LIBS) $(FVAD_LIBS) $(FREETYPE_LIBS) $(CURL_LIBS) $(PCRE_LIBS) $(SPEEX_LIBS) $(LIBEDIT_LIBS) $(SYSTEMD_LIBS) $(openssl_LIBS) $(PLATFORM_CORE_LIBS) $(TPL_LIBS) $(SPANDSP_LIBS) $(SOFIA_SIP_LIBS)
|
||||
libfreeswitch_la_DEPENDENCIES = $(BUILT_SOURCES)
|
||||
|
||||
if HAVE_PNG
|
||||
|
|
|
@ -4,6 +4,10 @@ After=syslog.target network.target
|
|||
After=postgresql.service postgresql-9.3.service postgresql-9.4.service mysqld.service httpd.service
|
||||
|
||||
[Service]
|
||||
# You can use Type=notify only if you compile FreeSWITCH with --enable-systemd configure option
|
||||
# In this case you have to run FreeSWITCH in foreground mode (-nf option)!
|
||||
#Type=notify
|
||||
#NotifyAccess=main
|
||||
User=freeswitch
|
||||
EnvironmentFile=-/etc/sysconfig/freeswitch
|
||||
# RuntimeDirectory is not yet supported in CentOS 7. A workaround is to use /etc/tmpfiles.d/freeswitch.conf
|
||||
|
|
11
configure.ac
11
configure.ac
|
@ -1578,6 +1578,17 @@ AS_IF([test "x$enable_core_libedit_support" != "xno"],[
|
|||
AC_MSG_ERROR([You need to either install libedit-dev (>= 2.11) or configure with --disable-core-libedit-support])
|
||||
])])])
|
||||
|
||||
AC_ARG_ENABLE(systemd,
|
||||
[AS_HELP_STRING([--enable-systemd], [Compile with systemd notify support])])
|
||||
|
||||
AS_IF([test "x$enable_systemd" = "xyes"],[
|
||||
PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 219], [
|
||||
AC_DEFINE([HAVE_SYSTEMD], [1], [Define to 1 if systemd is available])])
|
||||
])
|
||||
|
||||
AC_SUBST(SYSTEMD_LIBS)
|
||||
|
||||
|
||||
dnl ---------------------------------------------------------------------------
|
||||
dnl - OpenLDAP SDK
|
||||
dnl ---------------------------------------------------------------------------
|
||||
|
|
|
@ -73,6 +73,10 @@
|
|||
#define pclose _pclose
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYSTEMD
|
||||
#include <systemd/sd-daemon.h>
|
||||
#endif
|
||||
|
||||
SWITCH_DECLARE_DATA switch_directories SWITCH_GLOBAL_dirs = { 0 };
|
||||
SWITCH_DECLARE_DATA switch_filenames SWITCH_GLOBAL_filenames = { 0 };
|
||||
|
||||
|
@ -2558,6 +2562,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(switch_core_flag_t
|
|||
free(cmd);
|
||||
}
|
||||
|
||||
#ifdef HAVE_SYSTEMD
|
||||
sd_notifyf(0, "READY=1\n"
|
||||
"MAINPID=%lu\n", (unsigned long) getpid());
|
||||
#endif
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
}
|
||||
|
@ -2880,6 +2889,9 @@ SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, void *
|
|||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Restarting\n");
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Shutting down\n");
|
||||
#ifdef HAVE_SYSTEMD
|
||||
sd_notifyf(0, "STOPPING=1\n");
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
fclose(stdin);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue