[CentOS] systemctl (SOLVED)

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

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


<snip>

>> 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
channel.

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!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)

iQIcBAEBAgAGBQJVID9WAAoJEAF3yXsqtyBlCw0P/1N9PpMZ8MYlVljW1qPd4A9z
dblOiS/lerhx2GkqJZXbMCaJg1k5W54HUj8LztaNQhi4+B9GC2p2/PY1Gz3zAU4f
rryfi6yVffeEAgw2FlrtJXCPn9pgjr6tr2JZH+2dM2zqEp4UYLpbPmjNBrrkAzsm
najv0+05GTEMHKxMSQR8eKOfF02u7ccGJ68LvZUdJ2kGgCW9z7/lZcbCHQEc2NCS
06FiDTa2XmOk6i8RTpoIgpQ70ZGRZF7mP8IArRjvusmdvfGuwKoNgFdYiEtsVZIQ
+vHGyq20/SG/XnW83OpJ4gmDnA7wdpMY+InqA+UuPpz+yaP75MM5qF+fcAqTOE2N
1kAbe1x/z5FhVzRg8v758+TPW6zGX09w/wglaXrEWLMrI2WjSHr1nbaAUsZm+OkK
DYWcncf+Uj4XjNtL9UzdlmwlD2m3MgPVCAnoRQ8ncA4OMWkoll+vjkK1w6FngRo/
oMqnv+5g6gqDZVzc6VEBMObGTlizL74tiSiY1Fk0X5IiIH2CEMOzpGbXM1XMxh5C
dYG6VMfen6KaISRJplUhq8LJLm0s/Ntkz77wRjnKDV3rRJsrZygLCgP/qFrDhwF8
HtoZ1IOpe4bfyeUTpduOz5AAZfHTZAOkxdKgBus4WuSMYOeqcZZgoR7WvKXL4PA8
ae5VpcKDuhghLqc8ZhRF
=ZJ7p
-----END PGP SIGNATURE-----