[mythtv-users] SystemD (Was: Recommended Linux Distro post CentOS)

Stephen Worthington stephen_agent at jsw.gen.nz
Sun Dec 20 01:39:17 UTC 2020


On Sat, 19 Dec 2020 14:33:10 -0700, you wrote:

>On Sat, Dec 19, 2020 at 07:04:15PM +0000, Simon Hobson wrote:
>> Stephen Worthington <stephen_agent at jsw.gen.nz> wrote:
>> 
>> > You completely missed my point.  When I said "usually" and "often" I
>> > meant the that the very first time you try the .service file you have
>> > just written, it works.
>> 
>> No I got your point exactly. And when it doesn't - you have this "black box" you can't debug.
>
>Case in point is my systemd unit to start mythbackend.  It appparently fails.
>That's about all I have been able to get out of it.  But after the system
>boots, systemctl restart mythbackend gets it started just fine.
>
>Now, perhaps I'm missing some dependency.  I had thought it was probably the
>database, so I added /etc/systemd/system/mythbackend.service.d/local.conf
>(I'm using the standard fedora distributed mythbackend.service file) with
>
>[Install]
>Requires=mariadb.service
>After=mariadb.service
>
>And, just for good measure, I added:
>
>[Service]
>Restart=always
>RestartSec=3
>
>It would seem that even if it fails after reboot, the Restart directive
>would make systemd re-try every 3 seconds.  Yet, mythbackend fails to
>start up the first time and systemd gives up.
>
>So, I've spent enough time trying to figure out why systemd isn't doing its
>job and now I just manually start it.
>
>Progress...
>
>marcus hall

How about giving us a bit more detail about the problem so we can
help?  The output into mythbackend.log and the output of "journalctl
-eu mythbackend" would be a start.  And "systemctl cat mythbackend",
so we can see exactly what the unit files are.

And how you are running your MythTV - do you have it set up as
accessible to other frontends, or is it using localhost only?

My chief suspects from your description are that mythbackend is
running before either the database is up or networking is up.  But in
either case, if it is set to log to syslog or mythbackend.log, there
should be error messages to tell you why it shut down again.  Since
you have added the Requires/After for mariadb that pretty much means
it is going to be networking that is not up.

Note that mariadb.service is normally aliased as mysql.service, so
when you are using MariaDB, any Wants/After lines for mysql will also
work with MariaDB.  If you check mythbackend.service, you should find
that it has Wants/After=mysql already in it.

Using "Restart=always" can be a big problem when you run up against a
new bug in an update of a program that causes it to crash at startup.
It will then keep on restarting and filling up the logs, until the
logs fill the partition and the system dies.  So it is normally best
to set a maximum number of retries.  I would suggest that you add
something like:

[Service]
StartLimitBurst=10
StartLimitInterval=60s

to prevent that.


More information about the mythtv-users mailing list