tango systemd integration

PICCA Frederic-Emmanuel frederic-emmanuel.picca at synchrotron-soleil.fr
Fri Jul 17 22:50:24 BST 2015


> Great!

will see if I can do something ;)

> We need a bit more detail on what your init scripts currently do. Most
> of the time the conversion is fairly simple (ie, just invoke the
> program with the correct options).

Let's do it slowly and start with tango-db
I put here a cut and past of the curren tinit script of tango-db

---8<-----

PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/lib/tango
DESC="Tango Control System - database"
NAME=tango-db
NAME_REAL=DataBaseds
CONFFILE=/etc/tangorc
PORT=`grep TANGO_HOST $CONFFILE | awk -F ":" '{print $2}'`
HOST=`grep TANGO_HOST $CONFFILE | awk -F ":" '{print $1}' | awk -F "=" '{print $2}'`
CANON_HOST=`grep TANGO_HOST $CONFFILE | awk -F ":" '{print $1}' | awk -F "=" '{print $2}' | awk -F "." '{print $1}'`
DAEMON=/usr/lib/tango/$NAME_REAL
DAEMON_USER=tango
DAEMON_GROUP=tango
PIDFILE=/var/run/$NAME.pid

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

#
# Function that starts the daemon/service
#
do_start()
{
        # Return
        #   0 if daemon has been started
        #   1 if daemon was already running
        #   2 if daemon could not be started

        # to start this daemon need a working network
        if [ $CANON_HOST = "localhost" ]
        then
                DAEMON_ARGS="2 -ORBendPoint giop:tcp:$HOST:$PORT"
        else
                DAEMON_ARGS="2 -ORBendPoint giop:tcp::$PORT"
                tango_admin --ping-network 40 || return 2
        fi
        start-stop-daemon --start --quiet --chuid $DAEMON_USER:$DAEMON_GROUP --background \
            --make-pidfile --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
            || return 1
        start-stop-daemon --start --quiet --chuid $DAEMON_USER:$DAEMON_GROUP --background \
            --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS \
            || return 2
        # Add code here, if necessary, that waits for the process to be ready
        # to handle requests from services started subsequently which depend
        # on this one.  As a last resort, sleep for some time.
        tango_admin --ping-database 6 || return 2
}

first I change the PATH to add /usr/lib/tango where the daemon executable can be found

as you can see there is some black magie in the do_start and a few constant at the begining of the code
the daemon args depends on the nameof the host
tango_admin is a tool which allow to check that the network is up and ready in order to start the daemon
then we start the daemon as a tango user instead of root.

at the end the tango_admin is used to check that the daemonis up and running
 tango_admin --ping-database 6 || return 2 (6 is for the number of retry)

> Also, what do you mean require a running mysql server? tango-db does
> not depend on mysql-server...

you are right

Package: tango-db
Source: tango
Version: 8.1.2c+dfsg-5
Installed-Size: 810
Maintainer: Debian Science Maintainers <debian-science-maintainers at lists.alioth.debian.org>
Architecture: i386
Depends: debconf (>= 0.5) | debconf-2.0, libc6 (>= 2.4), libcos4-1 (>= 4.1.6), libgcc1 (>= 1:4.1.1), liblog4tango5, libmysqlclient18 (>= 5.5.24+dfsg-1), libomniorb4-1 (>= 4.1.6), libomnithread3c2 (>= 4.0.6), libstdc++6 (>= 4.4.0), libtango8, libzmq3 (>= 3.2.3+dfsg), zlib1g (>= 1:1.1.4), dbconfig-common, libtango-tools, lsb-base
Recommends: mysql-client

but I rely on dbconfig-common in order to setup the sql datatbase when installing the package. (this is another story)
What is true is that the tango-db "daemon" can not start if it can not connect to a running database.
Which can be on the same host or another one (different topologies of network)

> You might want to take a look at the systemd.service manpage, there is
> an EXAMPLES section at the end which may be useful to get you started.

thanks I will take a look

cheers

Frederic



More information about the Pkg-systemd-maintainers mailing list