<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 3, 2022 at 11:56 AM Mike Perkins <<a href="mailto:mikep@randomtraveller.org.uk">mikep@randomtraveller.org.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 03/02/2022 16:47, James Abernathy wrote:<br>
> I think this failure is mine alone but it seems to fail because of an<br>
> override.conf file I have in the mythtv-backend.service.  It worked until<br>
> this update this morning.<br>
> <br>
> I don't see this reason for the error:<br>
> jim@kubuntu-closet:/etc/systemd/system/mythtv-backend.service.d$ sudo<br>
> systemctl cat mythtv-backend.service<br>
> # /lib/systemd/system/mythtv-backend.service<br>
> [Unit]<br>
> Description=MythTV Backend<br>
> Documentation=<a href="https://www.mythtv.org/wiki/Mythbackend" rel="noreferrer" target="_blank">https://www.mythtv.org/wiki/Mythbackend</a><br>
> After=mysql.service network.target<br>
> <br>
> [Service]<br>
> User=mythtv<br>
> EnvironmentFile=-/etc/mythtv/additional.args<br>
> ExecStart=/usr/bin/mythbackend --quiet --syslog local7 $ADDITIONAL_ARGS<br>
> StartLimitBurst=10<br>
> StartLimitInterval=10m<br>
> Restart=on-failure<br>
> RestartSec=1<br>
> <br>
> [Install]<br>
> WantedBy=multi-user.target<br>
> <br>
> # /etc/systemd/system/mythtv-backend.service.d/override.conf<br>
> [Service]<br>
> ExecStartPre=/usr/local/bin/hdhomerun_check.py<br>
> <br>
> I think the error with the upgrade is during the post processing. when it<br>
> tried to restart mythtv-backend.service. Here's the output from the restart<br>
> failure.<br>
> <br>
> jim@kubuntu-closet:/etc/systemd/system/mythtv-backend.service.d$ sudo<br>
> systemctl status mythtv-backend<br>
> × mythtv-backend.service - MythTV Backend<br>
>       Loaded: loaded (/lib/systemd/system/mythtv-backend.service; enabled;<br>
> vendor preset: enabled)<br>
>      Drop-In: /etc/systemd/system/mythtv-backend.service.d<br>
>               └─override.conf<br>
>       Active: failed (Result: exit-code) since Thu 2022-02-03 11:39:01 EST;<br>
> 14s ago<br>
>         Docs: <a href="https://www.mythtv.org/wiki/Mythbackend" rel="noreferrer" target="_blank">https://www.mythtv.org/wiki/Mythbackend</a><br>
>      Process: 3711 ExecStartPre=/usr/local/bin/hdhomerun_check.py<br>
> (code=exited, status=1/FAILURE)<br>
>          CPU: 86ms<br>
> <br>
> Feb 03 11:39:01 kubuntu-closet systemd[1]: mythtv-backend.service:<br>
> Scheduled restart job, restart counter is at 10.<br>
> Feb 03 11:39:01 kubuntu-closet systemd[1]: Stopped MythTV Backend.<br>
> Feb 03 11:39:01 kubuntu-closet systemd[1]: mythtv-backend.service: Start<br>
> request repeated too quickly.<br>
> Feb 03 11:39:01 kubuntu-closet systemd[1]: mythtv-backend.service: Failed<br>
> with result 'exit-code'.<br>
> Feb 03 11:39:01 kubuntu-closet systemd[1]: Failed to start MythTV Backend.<br>
> <br>
> I'll temporarily remove the override for now.<br>
> <br>
> Any ideas?<br>
> <br>
It's the hdhomerun python code that is failing. Has the version changed?<br>
<br>
-- <br>
<br>
Mike Perkins<br></blockquote><div><br></div><div>I have not changed the code. I got it from someone on MythTV Forum and it seemed simpler than wait-for-pingable method of delaying mythtv-backend startup.</div><div>Here's the code and it works normally at the command line.</div><div><br></div> cat /usr/local/bin/hdhomerun_check.py <br>#!/usr/bin/python3<br><br>''' See if the HD Homerun box is accessable and running '''<br><br>import subprocess<br>import sys<br>import logging<br>from time import sleep<br>from datetime import datetime<br><br>ATTEMPTS = 21<br>DELAY = 2<br><br><br>def get_elapsed_time(start):<br>    ''' Calculate the time spent waiting for the HDHR to come up '''<br><br>    delta = datetime.utcnow() - start<br>    rounded_delta = '{:.3f}'.format(delta.seconds +<br>                                    (delta.microseconds / 1000000))<br>    return rounded_delta<br><br><br>def main():<br>    ''' Try to discover the HDHR '''<br><br>    attempt = 0  # Shut up pylint.<br>    command = 'hdhomerun_config discover'<br>    logger = logging.getLogger(command)<br><br>    logging.basicConfig(filename='/var/log/mythtv/hdhr_discovery.log',<br>                        filemode='a',<br>                        format='%(asctime)s %(levelname)s\t%(message)s',<br>                        datefmt='%Y-%m-%d %H:%M:%S',<br>                        level=logging.INFO)<br><br>    <a href="http://logger.info">logger.info</a>('Starting HD Homerun discovery')<br><br>    start = datetime.utcnow()<br><br>    for attempt in range(1, ATTEMPTS):<br>        try:<br>            sproc = subprocess.Popen(command, stdout=subprocess.PIPE,<br>                                     shell=True)<br>            sproc.communicate()<br><br>        except KeyboardInterrupt:<br>            sys.exit(2)<br><br>        if sproc.returncode != 0:<br>            logger.warning('%s failed, return code = %d.', command,<br>                           sproc.returncode)<br>            sleep(DELAY)<br>        else:<br>            <a href="http://logger.info">logger.info</a>('Found HD Homerun. Seconds=%s, attempts=%d.',<br>                        get_elapsed_time(start), attempt)<br>            sys.exit(0)<br><br>    logger.error('Couldn\'t find HD Homerun. Seconds=%s, attempts=%d.',<br>                 get_elapsed_time(start), attempt)<br><br><br>if __name__ == '__main__':<br>    main()<br><br># vim: set expandtab tabstop=4 shiftwidth=4 smartindent colorcolumn=80:<br><div> </div><div>Jim A<br><br></div></div></div>