[mythtv-users] Make mythbackend shutdown quicker when frontends disconnect uncleanly

Mark Perkins perkins1724 at hotmail.com
Sat Oct 14 20:41:41 UTC 2017


On 15 October 2017 3:07:53 am Andrew Wilkinson <andrewjwilkinson at gmail.com> 
wrote:

> Hi,
>
> I have a Raspberry Pi as a remote frontend which is powered on and off with 
> the TV. This means it doesn’t disconnect cleanly, it is just abruptly 
> terminated. I have a read-only SD card, so I’m not worried about the Pi, 
> but it does have the unfortunate side effect of making the backend stay 
> awake for 2.5 hours after the TV is turned off. If the backend turns on to 
> record it shuts down two minutes after the recording finishes.
>
> I’ve included some of the logs from the backend below. You can see the 
> frontend pitv is turned on at 12:08, and the Monitor socket is disconnected 
> at 12:41 when the Pi is turned off. The Playback socket doesn’t disconnect 
> until 14:36. Is there a way to reduce the timeout on this socket so the 
> disconnected frontend is detected more quickly, and the backend will shutdown?
>
> Oct 13 12:08:37 tv mythbackend: mythbackend[1255]: I ProcessRequest 
> mainserver.cpp:1735 (HandleAnnounce) MainServer: adding: pitv(1f0e370) as a 
> client (events: 0)
> Oct 13 12:08:37 tv mythbackend: mythbackend[1255]: I ProcessRequest 
> backendcontext.cpp:68 (SetFrontendConnected) BackendContext: Frontend 
> 'pitv' connected.
> Oct 13 12:08:37 tv mythbackend: mythbackend[1255]: I ProcessRequest 
> mainserver.cpp:1735 (HandleAnnounce) MainServer: adding: pitv(1e38a70) as a 
> client (events: 1)
> Oct 13 12:10:30 tv mythbackend: mythbackend[1255]: I ProcessRequest 
> mainserver.cpp:1735 (HandleAnnounce) MainServer: adding: pitv(1df1920) as a 
> client (events: 0)
> Oct 13 12:18:02 tv mythbackend: mythbackend[1255]: I MythSocketThread(87) 
> mainserver.cpp:7656 (connectionClosed) Playback sock(1df1920) 'pitv' 
> disconnected
> Oct 13 12:18:12 tv mythbackend: mythbackend[1255]: I ProcessRequest 
> mainserver.cpp:1735 (HandleAnnounce) MainServer: adding: pitv(1ef2d70) as a 
> client (events: 0)
> Oct 13 12:41:12 tv mythbackend: mythbackend[1255]: I MythSocketThread(62) 
> mainserver.cpp:7656 (connectionClosed) Monitor sock(1e38a70) 'pitv' 
> disconnected
> Oct 13 14:36:36 tv mythbackend: mythbackend[1255]: I MythSocketThread(87) 
> mainserver.cpp:7656 (connectionClosed) Playback sock(1ef2d70) 'pitv' 
> disconnected
> Oct 13 14:36:38 tv mythbackend: mythbackend[1255]: I MythSocketThread(52) 
> backendcontext.cpp:102 (SetFrontendDisconnected) BackendContext: Frontend 
> 'pitv' disconnected.
> Oct 13 14:36:38 tv mythbackend: mythbackend[1255]: I MythSocketThread(52) 
> mainserver.cpp:7656 (connectionClosed) Playback sock(1f0e370) 'pitv' 
> disconnected
> Oct 13 14:36:44 tv mythbackend: mythbackend[1255]: N Scheduler 
> scheduler.cpp:2985 (HandleIdleShutdown) I'm idle now... shutdown will occur 
> in 120 seconds.
>
> Many thanks,
> Andrew
>

I am thinking about setting up something similar in the not to distant 
future. My thoughts on this were to attempt to use CEC to shut down the tv, 
perhaps in a shutdown script if necessary but perhaps not. ie let the pi 
shutdown the tv when it is done or let the tv detect when the pi is turned 
off - instead of powering off the TV by remote.

Depends if your TV is CEC capable of course.




More information about the mythtv-users mailing list