mirror of
https://github.com/coturn/coturn.git
synced 2025-10-24 12:31:00 +02:00
Add systemd notification support
This commit is contained in:
parent
ae0b41153c
commit
ef7916842d
@ -33,6 +33,7 @@ Version 4.5.2 'dan Eider':
|
||||
- Version number is changed to semver 2.0
|
||||
- Merge PR #288 (by Hristo Venev)
|
||||
* pkg-config, and various cleanups in connfigure file
|
||||
- Add systemd notification for better systemd integration
|
||||
|
||||
24/06/2020 Oleg Moskalenko <mom040267@gmail.com> Mihály Mészáros <misi@majd.eu>
|
||||
Version 4.5.1.3 'dan Eider':
|
||||
|
||||
@ -158,6 +158,8 @@ Flags:
|
||||
|
||||
-o, --daemon Run server as daemon.
|
||||
|
||||
--systemd Notify systemd about server status. (Use only in forground!)
|
||||
|
||||
--no-software-attribute Production mode: hide the software version.
|
||||
|
||||
-f, --fingerprint Use fingerprints in the TURN messages. If an incoming request
|
||||
|
||||
15
configure
vendored
15
configure
vendored
@ -864,6 +864,21 @@ else
|
||||
OSCFLAGS="${OSCFLAGS} -DTURN_NO_PROMETHEUS"
|
||||
fi
|
||||
|
||||
###########################
|
||||
# Test libsystemd
|
||||
###########################
|
||||
|
||||
if [ -z "${TURN_NO_SYSTEMD}" ] ; then
|
||||
if testpkg_common libsystemd; then
|
||||
${ECHO_CMD} "Systemd library found."
|
||||
else
|
||||
${ECHO_CMD} "Systemd library not found. Building without systemd support."
|
||||
TURN_NO_PQ="-DTURN_NO_SYSTEMD"
|
||||
fi
|
||||
else
|
||||
TURN_NO_PQ="-DTURN_NO_SYSTEMD"
|
||||
fi
|
||||
|
||||
###########################
|
||||
# Test SQLite3 setup
|
||||
###########################
|
||||
|
||||
@ -6,7 +6,7 @@ ENV BUILD_PREFIX /usr/local/src
|
||||
# Install build dependencies
|
||||
RUN export DEBIAN_FRONTEND=noninteractive && \
|
||||
apt-get update && \
|
||||
apt-get install -y build-essential git debhelper dpkg-dev libssl-dev libevent-dev sqlite3 libsqlite3-dev postgresql-client libpq-dev default-mysql-client default-libmysqlclient-dev libhiredis-dev libmongoc-dev libbson-dev
|
||||
apt-get install -y build-essential git debhelper dpkg-dev libssl-dev libevent-dev sqlite3 libsqlite3-dev postgresql-client libpq-dev default-mysql-client default-libmysqlclient-dev libhiredis-dev libmongoc-dev libbson-dev libsystemd-dev
|
||||
|
||||
# Clone Coturn
|
||||
WORKDIR ${BUILD_PREFIX}
|
||||
|
||||
@ -9,12 +9,10 @@ Wants=network-online.target
|
||||
[Service]
|
||||
User=turnserver
|
||||
Group=turnserver
|
||||
Type=forking
|
||||
Type=notify
|
||||
RuntimeDirectory=turnserver
|
||||
PIDFile=/run/turnserver/turnserver.pid
|
||||
ExecStart=/usr/bin/turnserver --daemon -c /etc/turnserver.conf --pidfile /run/turnserver/turnserver.pid
|
||||
#FixMe: turnserver exit faster than it is finshing the setup and ready for handling the connection.
|
||||
ExecStartPost=/bin/sleep 2
|
||||
ExecStart=/usr/bin/turnserver --systemd -c /etc/turnserver.conf --pidfile /run/turnserver/turnserver.pid
|
||||
Restart=on-failure
|
||||
InaccessibleDirectories=/home
|
||||
PrivateTmp=yes
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
.\" Text automatically generated by txt2man
|
||||
.TH TURN 1 "05 January 2021" "" ""
|
||||
.TH TURN 1 "07 January 2021" "" ""
|
||||
.SH GENERAL INFORMATION
|
||||
|
||||
\fIturnadmin\fP is a TURN administration tool. This tool can be used to manage
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
.\" Text automatically generated by txt2man
|
||||
.TH TURN 1 "05 January 2021" "" ""
|
||||
.TH TURN 1 "07 January 2021" "" ""
|
||||
.SH GENERAL INFORMATION
|
||||
|
||||
The \fBTURN Server\fP project contains the source code of a TURN server and TURN client
|
||||
@ -230,6 +230,10 @@ Extra verbose mode, very annoying and not recommended.
|
||||
.B
|
||||
\fB\-o\fP, \fB\-\-daemon\fP
|
||||
Run server as daemon.
|
||||
.TP
|
||||
.B
|
||||
\fB\-\-systemd\fP
|
||||
Notify systemd about server status. (Use only in forground!)
|
||||
.PP
|
||||
\fB\-\-no\-software\-attribute\fP Production mode: hide the software version.
|
||||
.TP
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
.\" Text automatically generated by txt2man
|
||||
.TH TURN 1 "05 January 2021" "" ""
|
||||
.TH TURN 1 "07 January 2021" "" ""
|
||||
.SH GENERAL INFORMATION
|
||||
|
||||
A set of turnutils_* programs provides some utility functionality to be used
|
||||
|
||||
@ -6,10 +6,10 @@ After=syslog.target network.target
|
||||
[Service]
|
||||
User=turnserver
|
||||
Group=turnserver
|
||||
Type=forking
|
||||
Type=notify
|
||||
EnvironmentFile=/etc/sysconfig/turnserver
|
||||
PIDFile=/var/run/turnserver/turnserver.pid
|
||||
ExecStart=/usr/bin/turnserver -o -c /etc/turnserver/turnserver.conf $EXTRA_OPTIONS
|
||||
ExecStart=/usr/bin/turnserver --systemd -c /etc/turnserver/turnserver.conf $EXTRA_OPTIONS
|
||||
ExecStopPost=/usr/bin/rm -f /var/run/turnserver/turnserver.pid
|
||||
Restart=on-abort
|
||||
|
||||
|
||||
@ -170,7 +170,8 @@ DEFAULT_CPUS_NUMBER,
|
||||
0, /* no_dynamic_ip_list */
|
||||
0, /* no_dynamic_realms */
|
||||
|
||||
0 /* log_binding */
|
||||
0, /* log_binding */
|
||||
0 /* systemd */
|
||||
};
|
||||
|
||||
//////////////// OpenSSL Init //////////////////////
|
||||
@ -463,6 +464,7 @@ static char Usage[] = "Usage: turnserver [options]\n"
|
||||
" -v, --verbose 'Moderate' verbose mode.\n"
|
||||
" -V, --Verbose Extra verbose mode, very annoying (for debug purposes only).\n"
|
||||
" -o, --daemon Start process as daemon (detach from current shell).\n"
|
||||
" --systemd Notify systemd about server status. (Use only in forground!)\n"
|
||||
" --no-software-attribute Production mode: hide the software version (formerly --prod).\n"
|
||||
" -f, --fingerprint Use fingerprints in the TURN messages.\n"
|
||||
" -a, --lt-cred-mech Use the long-term credential mechanism.\n"
|
||||
@ -813,7 +815,8 @@ enum EXTRA_OPTS {
|
||||
NO_HTTP_OPT,
|
||||
SECRET_KEY_OPT,
|
||||
ACME_REDIRECT_OPT,
|
||||
LOG_BINDING_OPT
|
||||
LOG_BINDING_OPT,
|
||||
SYSTEMD_OPT
|
||||
};
|
||||
|
||||
struct myoption {
|
||||
@ -949,6 +952,7 @@ static const struct myoption long_options[] = {
|
||||
{ "keep-address-family", optional_argument, NULL, 'K' },
|
||||
{ "acme-redirect", required_argument, NULL, ACME_REDIRECT_OPT },
|
||||
{ "log-binding", optional_argument, NULL, LOG_BINDING_OPT },
|
||||
{ "systemd", optional_argument, NULL, SYSTEMD_OPT },
|
||||
|
||||
{ NULL, no_argument, NULL, 0 }
|
||||
};
|
||||
@ -1606,6 +1610,9 @@ static void set_option(int c, char *value)
|
||||
case LOG_BINDING_OPT:
|
||||
turn_params.log_binding = get_bool_value(value);
|
||||
break;
|
||||
case SYSTEMD_OPT:
|
||||
turn_params.systemd = get_bool_value(value);
|
||||
break;
|
||||
|
||||
/* these options have been already taken care of before: */
|
||||
case 'l':
|
||||
|
||||
@ -85,6 +85,10 @@
|
||||
#include <openssl/modes.h>
|
||||
#endif
|
||||
|
||||
#if !defined(TURN_NO_SYSTEMD)
|
||||
#include <systemd/sd-daemon.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -335,6 +339,8 @@ typedef struct _turn_params_ {
|
||||
|
||||
vint log_binding;
|
||||
|
||||
vint systemd;
|
||||
|
||||
} turn_params_t;
|
||||
|
||||
extern turn_params_t turn_params;
|
||||
|
||||
@ -1590,6 +1590,11 @@ void run_listener_server(struct listener_server *ls)
|
||||
unsigned int cycle = 0;
|
||||
while (!turn_params.stop_turn_server) {
|
||||
|
||||
#if !defined(TURN_NO_SYSTEMD)
|
||||
if(turn_params.systemd)
|
||||
sd_notify (0, "READY=1");
|
||||
#endif
|
||||
|
||||
if (eve(turn_params.verbose)) {
|
||||
if ((cycle++ & 15) == 0) {
|
||||
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s: cycle=%u\n", __FUNCTION__, cycle);
|
||||
@ -1600,6 +1605,11 @@ void run_listener_server(struct listener_server *ls)
|
||||
|
||||
rollover_logfile();
|
||||
}
|
||||
|
||||
#if !defined(TURN_NO_SYSTEMD)
|
||||
if(turn_params.systemd)
|
||||
sd_notify (0, "STOPPING=1");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void setup_relay_server(struct relay_server *rs, ioa_engine_handle e, int to_set_rfc5780)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user