[mythtv-users] culprit found? (was: Web Frontend stopped working yesterday)

Stephen Worthington stephen_agent at jsw.gen.nz
Sun Jul 21 08:47:42 UTC 2019


On Sun, 21 Jul 2019 03:01:36 -0500, you wrote:

>On Sat, Jul 20, 2019 at 3:12 AM Stephen Worthington <
>stephen_agent at jsw.gen.nz> wrote:
>
>> On Fri, 19 Jul 2019 20:33:13 +0200, you wrote:
>>
>> >On Fri, Jul 19 2019 at 13:54 -04, David Hampton wrote:
>> >> On Fri, 2019-07-19 at 18:34 +0200, Janusz S. Bie? wrote:
>> >>> On Fri, Jul 19 2019 at 11:59 -04, Jay Harbeston wrote:
>> >
>> >[...]
>> >
>> >>> If ps says the truth, there is only one backend running:
>> >>>
>> >>> --8<---------------cut here---------------start------------->8---
>> >>> ps ax | grep mythbackend
>> >>>  1295 ?        Ssl    3:04 /usr/bin/mythbackend --logpath
>> >>> /var/log/mythtv --logl
>> >>>  8222 pts/1    S+     0:00 grep mythbackend
>> >>>  --8<---------------cut here---------------end--------------->8---
>> >>>
>> >>> If nmap says the truth, the port 6543 is open and assigned to mythtv
>> >>> service:
>> >>>
>> >>> --8<---------------cut here---------------start------------->8---
>> >>> nmap -p 6543 0.0.0.0
>> >>> Starting Nmap 7.70 ( https://nmap.org ) at 2019-07-19 18:21 CEST
>> >>> Nmap scan report for 0.0.0.0
>> >>> Host is up (0.00013s latency).
>> >>>
>> >>> PORT     STATE SERVICE
>> >>> 6543/tcp open  mythtv
>> >>> --8<---------------cut here---------------end--------------->8---
>> >>>
>> >>> If the message
>> >>>
>> >>> 0.0.0.0:6543 - ERROR 8: THE BOUND ADDRESS IS ALREADY IN USE
>> >>>
>> >>> is the true, then some other mythtv service (is there any?) is using
>> >>> it...
>> >>
>> >> Try the command: sudo netstat -tapn | grep 6543
>> >
>> >Thanks, I was not familiar with this invocation.
>> >
>> >
>> >> That will tell you what process pid/name has the port open.
>> >
>> >--8<---------------cut here---------------start------------->8---
>> > netstat -tapn | grep 6543
>> >
>> >tcp        0      0 0.0.0.0:6543            0.0.0.0:*
>>  LISTEN      1295/mythbackend
>> >tcp6       0      0 :::6543                 :::*
>> LISTEN      1295/mythbackend
>> >
>> >ps ax | grep mythbackend
>> > 1295 ?        Ssl    6:33 /usr/bin/mythbackend --logpath /var/log/mythtv
>> --loglevel crit
>> >13947 pts/1    S+     0:00 grep mythbackend
>> >--8<---------------cut here---------------end--------------->8---
>> >
>> >I just realized that I have both mythbackend and mythtv-backend and my
>> system
>> >toggles between mythbackend and mythtv-backend in a semi-random way
>> >without my intervention. The change can be causes e.g. by some package
>> >update or reboot.
>> >
>> >When mythbackend is running then WebFrontend seems to work.
>> >
>> >Looks like mythbackend is started by systemd, and mythtv-backend by
>> >init. Now the question is how to get rid of mythtv-backend.
>> >
>> >Best regards
>> >
>> >Janusz
>>
>> You can either disable the /etc/init.d script, or you can rename your
>> mythbackend.service file to mythtv-backend.service, in which case
>> systemd will ignore the init script in favour of the proper systemd
>> unit.  To disable the init script, I think this is the right way to do
>> it:
>>
>> update-rc.d mythtv-backend disable
>>
>> His current systemd unit for mythtv-backend calls the init script as it's
>start=

Not a good idea!  Running update-rc.d disable would then disable
mythbackend completely.  It would be much better to install a proper
systemd .service file for running mythbackend directly.  Systemd's
handling of init scripts is very bad - it goes wrong in many different
ways, so it is not at all unlikely that the mythtv-backend init script
was being run from the .service unit and also directly via systemd's
init script support.  And init scripts are bad things anyway - they
have to be quite complicated bits of programming to work properly.
There are now good .service files for mythbackend, so there is no
reason not to be using one, and completely disabling the init script.

I have forgotten what distro is being used by the OP - but I would be
happy to help with a proper .service file.  It makes life so much
easier.  Here is what I am using on Ubuntu 18.04 (this is the output
of "systemctl cat mythtv-backend":

[Unit]
Description=MythTV Backend
Documentation=https://www.mythtv.org/wiki/Mythbackend
After=mysql.service network.target

[Service]
User=mythtv
EnvironmentFile=-/etc/mythtv/additional.args
ExecStart=/usr/bin/mythbackend --quiet --syslog local7
$ADDITIONAL_ARGS
StartLimitBurst=10
StartLimitInterval=10m
Restart=on-failure
RestartSec=1

[Install]
WantedBy=multi-user.target

#
/etc/systemd/system/mythtv-backend.service.d/mythtv-backend-override.conf
[Unit]

Wants=mysql.service
After=mysql.service
Wants=local-network-pingable.service
After=local-network-pingable.service

Wants=dev-dvb-adapter0-frontend0.device
After=dev-dvb-adapter0-frontend0.device
Wants=dev-dvb-adapter1-frontend0.device
After=dev-dvb-adapter1-frontend0.device
Wants=dev-dvb-adapter2-frontend0.device
After=dev-dvb-adapter2-frontend0.device
Wants=dev-dvb-adapter3-frontend0.device
After=dev-dvb-adapter3-frontend0.device
Wants=dev-dvb-adapter4-frontend0.device
After=dev-dvb-adapter4-frontend0.device

Wants=mnt-rec1.mount
After=mnt-rec1.mount
Wants=mnt-rec2.mount
After=mnt-rec2.mount
Wants=mnt-rec3.mount
After=mnt-rec3.mount
Wants=mnt-rec4.mount
After=mnt-rec4.mount
Wants=mnt-rec5.mount
After=mnt-rec5.mount
Wants=mnt-rec6.mount
After=mnt-rec6.mount
Wants=mnt-rec7.mount
After=mnt-rec7.mount

Wants=mnt-vid1.mount
Wants=mnt-vid2.mount
Wants=mnt-vid3.mount
Wants=mnt-vid4.mount

Wants=minisatip.service
After=minisatip.service


OnFailure=notify-failure@%n.service

[Service]
ExecStartPre=-/bin/bash /usr/local/bin/rm.test
ExecStop=/usr/local/bin/mythbackendstop.sh
StartLimitBurst=10
StartLimitInterval=10s
SendSIGKILL=yes
TimeoutStopSec=10

So you can see I have added all sorts of useful things for myself that
would not be easy to do with an init script.


More information about the mythtv-users mailing list