3

I am writing my own service daemon for Fedora 23 and I stucked, when my script hangs while including source function library.

#!/bin/sh
#
# service-live-text-relation <summary>
#
# chkconfig:   2345 80 20
# description: Starts and stops a single service-live-text-relation instance on this system
#

### BEGIN INIT INFO
# Provides: service-live-text-relation
# Required-Start: $network $named
# Required-Stop: $network $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: This service manages the service-live-text-relation daemon
# Description: service-live-text-relation
### END INIT INFO

#
# init.d / servicectl compatibility (openSUSE)
#
if [ -f /etc/rc.status ]; then
    . /etc/rc.status
    rc_reset
fi

echo "test1"

#
# Source function library.
#
if [ -f /etc/rc.d/init.d/functions ]; then
    . /etc/rc.d/init.d/functions
fi

#. /etc/init.d/functions

echo "test2";

#... further code goes here ...

I run following commands:

/bin/systemctl daemon-reload
chkconfig --add service-live-text-relation
chkconfig service-live-text-relation on
/bin/systemctl enable service-live-text-relation.service

When I run:

service service-live-text-relation start

I give the following output:

test1
Starting service-live-text-relation (via systemctl):

And the script hangs...

I have followed by example watching another scripts, but I cannot recognize what might be incorrect in my script.

  • add set -x somewhere near the top of the script (or, at least, before sourcing /etc/rc.d/init.d/functions which is where it seems to be hanging) to trace it. that might tell you where it hangs. – cas Jul 7 '16 at 10:34
3

I believe you are being bitten by systemd compatibility. In systemd-enabled systems, files in /etc/init.d are handled by systemd. The "service" command is just a shell script that tries to be "cute" (helpful) about starting a service for you. Have you tried just manually running '/etc/init.d/service-live-text-relation'?

I have no idea how the systemd compatibility works, so I can't help you there. If you have the proper "start", "stop", "restart" (etc) targets, like other init.d service control scripts, then I believe you can make them work.

But ... you really should be creating a systemd unit file instead. Perhaps try adding a unit file in /etc/systemd/user called 'service-live-text-relation.service'. Check out 'man systemd.service' (and all it's friends). It's becoming a systemd world, so you might as well update your start file. IMHO.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.