[mythtv] Dazed and Confused (Was Re: [mythtv-commits] Ticket #10236: Systemd Mythbackend startup does not check for existing process

Richard Shaw hobbes1069 at gmail.com
Sun Jan 8 00:35:19 UTC 2012


On Fri, Jan 6, 2012 at 4:48 PM, R. G. Newbury <newbury at mandamus.org> wrote:
> *****************************************
> Here is the Fedora 15 version. It uses Type=forking which (I think)
> means that systemd automagically restarts it if it crashes (I read
> something about that, but cannot find the reference now...of course!)

Nope, restarting is a separate option (Restart directive) and doesn't
have much to do with the type. Type forking means that it runs as a
traditional sysv type daemon where the process it starts under exits
and a separate process keeps running, which is why you need a PID
file. With Type=simple, systemd knows the PID because it runs under
the PID it starts under.

This also simplifies things because it makes the pre-start script
(below) unnecessary. SystemD already knows if its still running or
not. While SystemD supports a sysconfig file, it's more of a leftover
from SysV. The most important things can be controlled directly in the
systemd service file, as such, I've dropped it from the SystemD unit
file on F16+ (when I converted the RPM Fusion package to use SystemD,
F15 or older still uses a SysV script.


> See other messages for other history.
>
> *****************************************
> #/usr/local/bin/pre-start.sh
>
> #!/bin/bash
>
> # An 'is-running' check used to be performed by the old sysinit script
> # Instead we will kill any running process.
> if [ -e /var/run/mythtv/backend.pid ]; then
>     killall mythbackend;
> fi
> echo " Killed prior errant process"
>
> # Original unamended version from here on
>
> if [ ! -e /var/run/mythtv ]; then
>    mkdir /var/run/mythtv
> #   touch /var/run/mythtv/backend.pid;
> fi
>
> echo "Created pid folder"
> ******************************************
>
> ******************************************
> #! mythbackend.service for systemd
> # installed to /lib/systemd/system
> # amended only to change the user
>
> [Unit]
> Description=mythbackend daemon
> After=mysqld.service
>
> [Service]
> EnvironmentFile=/etc/sysconfig/mythbackend
> ExecStartPre=/usr/local/bin/pre-start.sh
> ExecStart=/usr/local/bin/mythbackend --daemon --user geoffrey --logfile
> /var/log/mythtv/backend.log --pidfile /var/run/mythtv/backend.pid
> PIDFile=/var/run/mythtv/backend.pid
> Type=forking
>
> [Install]
> WantedBy=multi-user.target
>
> *************************************
>
> Note that this would need an 'After=httpd.service' line if webmin is to
> be installed and used. I think multi-user.targer implies network.target
> already..

I default to network.target because HDHR tuners are pretty common, but
to be sure, yes, httpd.service should be there. Actually,
"Wants=httpd.service" would be more appropriate since it will keep the
startup from failing if it can't start or is not available (not
install/disabled).

Richard


More information about the mythtv-dev mailing list