[CentOS] systemctl (again)

Sat Apr 4 20:08:59 UTC 2015
J Martin Rushton <martinrushton56 at btinternet.com>

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

<snip>
> 
> This would be better served as the following to accomplish the
> immediate goal:
> 
> cat > /etc/systemd/system/timidity.service <<EOF [Unit] 
> Description=timidity daemon
> 
> [Service] User=jmr Group=users WorkingDirectory=/home/jmr 
> Type=forking ExecStart=/usr/bin/timidity -iAD EOF
> 
> systemctl daemon-reload
> 
> systemctl start timidity
> 
> You don't need to define an ExecStop and the type of the service 
> should be forking as you are daemonising it - simple if you didn't 
> daemonise it (or skip type which has this as default).
> 
> There is also no need to deal with the race condition mess that is
> a PID file with systemd as well... technically there is no need to
> mess with MAINPID in this scenario.

Points noted, I just took Andrew's file and changed the bare minimum.

> This is a quite messy though as you're running a 'system service'
> in the context of a regular user.... you were better off doing
> this within the user space as you started with.

It's getting rather windozy though if proper background system stuff
is moved into user space.  Multiple definitions of the D: drive
anyone? :-(

Running as jmr is purely temporary, ideally I will create a timidity
account for it, but for the present I just hacked Andrew's script to
ensure the user/group/directory worked.

> The reason that failed for you before is that you were making calls
> to systemctl without the --user option so it was trying to act in
> the system context.

Right, so user is user added code then.  I assumed it was for
site-local service files.

> However a google of "timidity systemd" has the arch wiki within
> the first few results that has good information which results in a 
> technically much nicer solution.
> 
> https://wiki.archlinux.org/index.php/Timidity#Daemon

Thanks.

> Note the --global option which makes it start on a per user basis
> when the session for that user starts. Also note they don't
> daemonise it as there is no real reason to with systemd controlling
> the process state.

It does need to be daemonised for frescobaldi to talk to it.  The
default (non-daemonised) way plays a file, if it is daemonised then it
sets up ports to listen on.  Hence the D modifier on the interface
switch.  I'll be honest though, when scanning for CentOS solutions I
would routinely ignore ArchLinix.

> If you want to stop/start/restart within the context of the user 
> session you should be doing systemctl --user start/stop/restart 
> timidity

No - I want it to start on boot and sit there like a good little
daemon doing what it's told.

> _______________________________________________ CentOS mailing
> list CentOS at centos.org 
> http://lists.centos.org/mailman/listinfo/centos
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)

iQIcBAEBAgAGBQJVIETbAAoJEAF3yXsqtyBluCMQALQmXr1j79saRLd3ulUD5L2W
rF3dZ4GCLwWJMlCE9ITwJZE5afimlYWLBsQXRDbdw+EZ8xLrUNfmL4aiGW77LIoK
cpkC1G/t3ZShUNjuu3pE4qxvBzSN3juLK8E9losaLKlpGaPlzqgVynZamyxX4kWp
PHTQM1tyOh8lcZcjvb2nn81A0fWKHzzi9aXHDFsejsntFUd0QzsKkFOuXLHJNY/P
yynX9fyiQ+1EvbjKL+i5ckMKMQg2ozdhTWzVtWqEZEHKu6ouaK+9+kiYM7k2Wy78
XrM/ccp/fEjMIcd8csaydg6N76oGrwGFhoIpuwbfk28wSiPX+RG1hmUN2zzXMNzw
XN5scxJpBnpsKGB6WmUHw7ELK04r26orO1hPJW//4voYWyT5kIC2vg4d2viPuHgD
zg7ogmUrTZAOa2Fh1dUXkYwLZyjT97hbteIj/hJBvpRJ42Gupnh5YDFmV29s1y8L
OnFKy4iBSn0dEHspkHDaHBXEPOkqwcSf0p1gfGG7QTP2CdeUeKq8nj/BbMYRPDpy
KsP7f6A0+xRTh+WTm74A1W4xGM9RIK58yoZ0+DcT318VvzjkVtYmbEILBjtz3Ag9
eiRWLLNiJvVn2tWBf5+p8YkELiJQknWk9bglYf9jmLzAegOm79QUwg53QGLMJ3Li
fTqMaOEqRUyJF6XOSY+9
=yqOD
-----END PGP SIGNATURE-----