TT#26264 Add systemd unit service file, remove sysvinit support

One reason to have full systemd support is to increase consistency when bringing
up and shutting down the system, or when restarting services, to have more
integration with the init system as a whole.

But apart from that reason, the original reason is that it has been noticed as
part of TT#31163 (service action tests) that the autogenerated unit file in
/run/systemd/generator.late/ngcp-sems.service does not properly depend on
MariaDB/MySQL (it had "After=mysql.service", but not Wants or Requires).

Unlike with sysvinit, with systemd the services are started in parallel, so
starting "after" another doesn't mean that the former is finished and fully
working by the time that the latter is ready.

Under these tests, this service sometimes fails to start, so it might be because
the DB is not ready (or at least it can be one of the reasons contributing to
the failure).  In any case, if it should start after "mysql" in sysvinit (or
"mariadb.service", as we're renaming it under systemd), SEMS probably assumes
that "mariadb.service" would be fully working, so the additional annotation
"Requires" is more correct than having only "After=mariadb.service".

As part of this change and since we are revamping the init support, we also
remove sysvinit support (including /etc/default/ngcp-sems) and delete or modify
some maintainer scripts referencing old sysvinit support.

Change-Id: I46b0b7b92fc6b13b467aafbb38e9383e88d0ad65
changes/45/19645/8
Manuel Montecelo 7 years ago
parent fde9945147
commit b471eefc22

@ -1,26 +0,0 @@
# configuration for SEMS - SIP Express Media Server
#
# this file is sourced by SEMS init script /etc/init.d/ngcp-sems
# Don't start with default config as we need to deploy the ngcp-templates first
SEMS_RUN="no"
# ser configuration file
SEMS_CFG_FILE="/etc/ngcp-sems/sems.conf"
# user to run ser as
SEMS_USER="sems"
# group to run ser as
SEMS_GROUP="sems"
SEMS_RUNDIR="/var/run/ngcp-sems"
# sems pidfile
SEMS_PIDFILE="$SEMS_RUNDIR/ngcp-sems.pid"
# set if you want to create core files
SEMS_CREATE_CORE="yes"
SEMS_CACHEDIR="/var/cache/ngcp-sems"
SEMS_CACHEDIR_EXTRADIRS="audio_cache callingcard"

@ -1,146 +0,0 @@
#! /bin/sh
### BEGIN INIT INFO
# Provides: ngcp-sems sems
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Should-Start: mysql
# Should-Stop: mysql
# Short-Description: Start/stop SEMS Application Server
### END INIT INFO
umask 0022
SEMS_CACHEDIR="/var/cache/ngcp-sems"
# read configuration from /etc/default/ngcp-sems file
if test -f /etc/default/ngcp-sems ; then
. /etc/default/ngcp-sems
fi
if test "$SEMS_RUN" = "no" ; then
echo "Sems start disabled by default file"
exit 0
fi
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/ngcp-sems
NAME=ngcp-sems
DESC=ngcp-sems
PARAMS=""
if ! test -d $SEMS_CACHEDIR ; then
mkdir -m 0755 -p $SEMS_CACHEDIR
fi
for dir in $SEMS_CACHEDIR_EXTRADIRS ; do
if ! test -d ${SEMS_CACHEDIR}/${dir} ; then
mkdir -m 0755 -p ${SEMS_CACHEDIR}/${dir}
fi
done
if ! test -d $SEMS_RUNDIR ; then
mkdir -m 0755 -p $SEMS_RUNDIR
fi
chown -R $SEMS_USER:$SEMS_GROUP $SEMS_RUNDIR $SEMS_CACHEDIR
if test "$SEMS_PIDFILE" ; then
PARAMS="$PARAMS -P $SEMS_PIDFILE"
fi
if test "$SEMS_USER" ; then
PARAMS="$PARAMS -u $SEMS_USER"
fi
if test "$SEMS_GROUP" ; then
PARAMS="$PARAMS -g $SEMS_GROUP"
fi
if test "$SEMS_CFG_FILE" ; then
PARAMS="$PARAMS -f $SEMS_CFG_FILE"
CFGPARAMS="-f $SEMS_CFG_FILE"
fi
if [ -x /usr/sbin/ngcp-virt-identify ]; then
if /usr/sbin/ngcp-virt-identify --type container; then
VIRT="yes"
fi
fi
if test "$SEMS_CREATE_CORE" = "yes" ; then
if [ "$VIRT" = "yes" ]; then
echo "Container environment detected. Skipping core dump configuration."
else
ulimit -c unlimited
fi
fi
if [ "$VIRT" = "yes" ]; then
echo "Container environment detected. Skipping file descriptors limit configuration."
else
# raise file descriptors limit - call hold consumes two fds for RTP ports and one for moh file
ulimit -n 100000
fi
if ! test -f $DAEMON ; then
echo "Error: cannot find $DAEMON"
exit 0
fi
LD_LIBRARY_PATH=/usr/lib/ngcp-sems
export LD_LIBRARY_PATH
set -e
. /lib/lsb/init-functions
case "$1" in
start)
if [ -x /usr/sbin/ngcp-check_active ]; then
if ! /usr/sbin/ngcp-check_active -q; then
echo "Ignored start action in inactive node"
exit 0
fi
fi
echo "Starting $DESC: $NAME"
start-stop-daemon --start --quiet --oknodo --pidfile $SEMS_PIDFILE \
--exec $DAEMON -- $PARAMS
log_end_msg $?
;;
stop)
echo -n "Stopping $DESC: $NAME"
start-stop-daemon --oknodo --stop --quiet --pidfile $SEMS_PIDFILE \
--signal 9 --exec $DAEMON
log_end_msg $?
;;
restart|force-reload)
echo "Restarting $DESC: $NAME"
start-stop-daemon --oknodo --stop --quiet --pidfile \
$SEMS_PIDFILE --signal 9 --exec $DAEMON
if [ -x /usr/sbin/ngcp-check_active ]; then
if ! /usr/sbin/ngcp-check_active -q; then
echo "Ignored start action in inactive node"
exit 0
fi
fi
sleep 5
start-stop-daemon --oknodo --start --quiet --pidfile \
$SEMS_PIDFILE --exec $DAEMON -- $PARAMS
echo "."
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
*)
N=/etc/init.d/$NAME
# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
exit 1
;;
esac
exit 0

@ -0,0 +1 @@
lib/systemd/system/ngcp-sems.service lib/systemd/system/sems.service

@ -1 +1,2 @@
ngcp-sems: possible-gpl-code-linked-with-openssl
ngcp-sems: init.d-script-not-included-in-package etc/init.d/ngcp-sems

@ -0,0 +1,2 @@
rm_conffile /etc/default/ngcp-sems 1:1.6.0-1+0~mr6.3.0.0+0~ ngcp-sems
rm_conffile /etc/init.d/ngcp-sems 1:1.6.0-1+0~mr6.3.0.0+0~ ngcp-sems

@ -2,14 +2,11 @@
set -e
dpkg-maintscript-helper rm_conffile /etc/default/sems -- "$@"
dpkg-maintscript-helper rm_conffile /etc/init.d/sems -- "$@"
case "$1" in
configure)
# add sems user
adduser --quiet --system --group --disabled-password --shell /bin/false \
--gecos "SIP Express Media Server" --home /var/run/ngcp-sems sems || true
--gecos "SIP Express Media Server" --home /run/ngcp-sems sems || true
;;
abort-upgrade|abort-remove|abort-deconfigure)
exit 0

@ -1,13 +0,0 @@
#!/bin/sh
set -e
if [ -x "/etc/init.d/sems" ]; then
update-rc.d sems remove >/dev/null
fi
dpkg-maintscript-helper rm_conffile /etc/default/sems -- "$@"
dpkg-maintscript-helper rm_conffile /etc/init.d/sems -- "$@"
#DEBHELPER#
exit 0

@ -0,0 +1,25 @@
[Unit]
Description=NGCP SIP Express Media Server (SEMS)
After=mariadb.service
After=network-online.target
After=remote-fs.target
Requires=mariadb.service
Requires=remote-fs.target
Wants=network-online.target
[Service]
Type=simple
User=sems
Group=sems
Environment=LD_LIBRARY_PATH=/usr/lib/sems-pbx
PassEnvironment=LD_LIBRARY_PATH
PIDFile=/run/ngcp-sems/ngcp-sems.pid
Restart=always
StartLimitInterval=10
StartLimitBurst=5
ExecStart=/usr/sbin/ngcp-sems -E -u sems -g sems -P /run/ngcp-sems/ngcp-sems.pid -f /etc/ngcp-sems/sems.conf
LimitNOFILE=100000
[Install]
WantedBy=multi-user.target
Alias=sems.service

@ -0,0 +1,4 @@
d /run/ngcp-sems 0755 sems sems
d /var/cache/ngcp-sems 0755 sems sems
d /var/cache/ngcp-sems/audio_cache 0755 sems sems
d /var/cache/ngcp-sems/callingcard 0755 sems sems

5
debian/rules vendored

@ -45,6 +45,11 @@ override_dh_auto_install:
dh_python2
dh_python2 /usr/lib/$(APP_NAME)
# config file needed to create cache and run dirs with tmpfiles.d (there
# is no .install file to make )
mkdir -p $(CURDIR)/debian/$(APP_NAME)/usr/lib/tmpfiles.d/
cp $(CURDIR)/debian/ngcp-sems.tmpfiles.d.conf $(CURDIR)/debian/$(APP_NAME)/usr/lib/tmpfiles.d/ngcp-sems.conf
override_dh_strip:
dh_strip --dbgsym-migration='$(APP_NAME)-dbg (<= 1:1.6.0-1+0~mr6.0.0.0)'
# MT#7431 those binaries aren't automatically stripped

Loading…
Cancel
Save