[CentOS] systemctl (SOLVED)

Sat Apr 4 19:45:26 UTC 2015
J Martin Rushton <martinrushton56 at btinternet.com>

Hash: SHA1


>> The process exited, so systemd thinks the service has exited.
>> You have a '-D' option, which probably means daemonize, but you
>> haven't set an appropriate Type declaration in the service file.
>> If the service offers it, the best way to do simple services
>> with systemd is with *foreground* options in ExecStart.  Then set
>> Type=simple. STDOUT/STDERR all goes to the journal, making it
>> easier to see what happens if the service legitimately fails.
>> Take a look at packaged files in /usr/lib/systemd/system - plenty
>> of examples to work from.
>> --Pete _______________________________________________ CentOS
>> mailing list CentOS at centos.org 
>> http://lists.centos.org/mailman/listinfo/centos
> Is $MAINPID defined in your pidfile?
> It sounds to me like only the 'kill' is exiting with a non-zero
> exit code because the variable is undefined.

Taking the above in order:

1)	Yes the "D" does mean deamonise, as I mentioned previously.
However it is not -i -A -D, but -i (interface is) A (Alsa, modified
by) D (run as a deamon).  Confusingly -D on its own refers to the drum

2)	-iA reads a file name as argument 1 and plays that.  -iAD sets up
sequencer ports to which an external program can write.

3)	I've use Type=forking, with some success - see below.

4)	pidfile wasn't being created.

When I tried a startup the command hung for several minutes before
returning with and error message.  Also for the first time I was
seeing output from timidity in messages.  There was the usual clutch
of SELinux messages, and although I am running permissive during test
I created the policy modules to stop them.  The status showed that
systemd could not read the pidfile, then it claimed that timidity had
timed out.  Next timidity logged its successful startup mesages before
systemd claimed to have failed to start it!

Just out of interest I touched the pidfile and chmod'ed it 777.
Suddenly it all worked!  Systemd is spawning off timidity as user jmr,
and timidity was not then able to create a file in /var/run.  Failry
obvious once you see it.

So: Thanks to all who have helped.  The principle lessons learnt seem
to be:

1)	Irrespective of the README in /etc/init.d, traditional init scripts
will not work unless they fit some assumed and undocumented model.  Do
not waste time trying to use them.

2)	/etc/systemd/user is borked in my version of CentOS: systemctl
doesn't read files from there.

3)	systemd must never be considered a simple replacement for init
files, any attempt to use it in the same way is doomed to failure.
You need to allow a few man-days to achieve success.  Hopefully the
time needed will reduce with experience, but I'll certainly not be
upgrading any production servers until I'm forced to!
Version: GnuPG v2.0.22 (GNU/Linux)