[mythtv] Systemd expertise needed: systemctl fails to start mythbackend

R. G. Newbury newbury at mandamus.org
Thu Jul 5 22:21:06 UTC 2012


On 07/05/2012 05:17 PM, Richard Shaw wrote:
> If you use --daemon you need to specify a PID file because systemd has
> no way of knowing what the PID of the forked process is without one.
>
> Before I figured that out I wrote the below which you may still find useful...
>
> Richard
>
>
> Does the backend need to run as a certain user? It's possible that
> systemd isn't running as the same user as your are manually.
>
> Here's an excerpt of the service file I use for Fedora/RPM Fusion:
>
> [Unit]
> Description=MythTV backend service
> After=network.target mysqld.service
> # uncomment the following line if you will be using the mythweb plugin.
> #Wants=httpd.service
>
> [Service]
> Type=simple
> Environment=MYTHCONFDIR=/etc/mythtv
> Environment=HOME=/usr/share/mythtv
> User=mythtv
> ExecStart=/usr/bin/mythbackend --logpath /var/log/mythtv
>
> [Install]
> WantedBy=multi-user.target
> --- end ---
>
> Type forking is assumed unless you say otherwise. In that case you
> will need to specify --daemon, but with systemd it's actually better
> to run Type=simple and not use the --daemon option so you don't have
> to mess with a PID file.

Thanks Richard. I have been using a variant of your service file for 
some time now. *With* user=mythtv.
I was under the impression (from something I read) that pidfile was not 
needed. That may have been in reference to mysqld..

So I added --pidfile /run/mythtv/backend.pid (using forking and daemon)
This fails but now reports 'deactivating' (not 'failed') until I kill 
mythlogserver. The log file message is the same 'failed init 
MythContext'. As before, the cli startup is fine.

With pidfile and simple (no daemon and no ExecStartPre), I get this:

root at tor6 mythtv]# systemctl start mythbackend.service
[root at tor6 mythtv]# systemctl status mythbackend.service
mythbackend.service - mythbackend daemon
           Loaded: loaded (/usr/lib/systemd/system/mythbackend.service; 
enabled)
           Active: deactivating (stop-sigterm) (Result: exit-code) since 
Thu, 05 Jul 2012 18:06:17 -0400; 2s ago
          Process: 5713 ExecStart=/usr/local/bin/mythbackend --logpath 
/var/log/mythtv --loglevel crit --pidfile /run/mythtv/backend.pid 
(code=exited, status=130)
           CGroup: name=systemd:/system/mythbackend.service
                   └ 5730 /usr/local/bin/mythlogserver --daemon 
--verbose general --logpath /var/l...

Jul 05 18:06:15 tor6.mandamus.org mythbackend[5713]: 2012-07-05 
18:06:15.254231 C  mythbackend ve...rg
Jul 05 18:06:15 tor6.mandamus.org mythbackend[5713]: 2012-07-05 
18:06:15.254269 C  Qt version: co....2
Jul 05 18:06:15 tor6.mandamus.org mythbackend[5713]: 2012-07-05 
18:06:15.254276 N  Enabled verbos...al
Jul 05 18:06:17 tor6.mandamus.org mythbackend[5713]: No UPnP backends found
Jul 05 18:06:17 tor6.mandamus.org mythbackend[5713]: Would you like to 
configure the database con...o]
Jul 05 18:06:17 tor6.mandamus.org mythbackend[5713]: [console is not 
interactive, using default 'no']
Jul 05 18:06:17 tor6.mandamus.org mythbackend[5713]: 2012-07-05 
18:06:17.317454 C  Failed to init...t.

The actual startup fails with code=extied, status=130). I have been 
unable to find any description of systemd error code messages.

The import of the last lines, is that mythbackend cannot talk to the 
mysqld server...which it does, when started from the command line...The 
logfile repeats its same refrain.

Same results using user=root group=root in the service file.

I'm wondering if systemd is blocking interprocess communications until 
it* thinks the new program is stable and has started properly? 
Meanwhile, the backend attempts to contact the mysqld server, which fails.

Geoff













More information about the mythtv-dev mailing list