Page 1 of 1

Myth Shutdown Shortly After Waking

Posted: Sun Jul 12, 2020 9:46 am
by MoisiePants
Hello:

I've been configuring shutdown on my system (macOS 10.12, MythTV 29.1ish) on and off for quite a while - and it's mostly working now. However I'm finding that it goes to sleep shortly after waking for a recording - causing the recording to fail.

I've got the following set:
In MythSetup:
- Wake before recording: 300 sec
- Max Wait for recording: 15 min
- Idle shutdown time: 600 sec
In MythFrontEnd (though I actually use Kodi as a frontend):
- Time to record before start of show: 180 sec

Here's what happened when I set the system to record a programme at 10:20 this morning. I woke the system at 10:25 to see what was going on:

Code: Select all

2020-07-12 09:22:56.605714 I [16271/192515] MythSocketThread(126) mainserver.cpp:7643 (connectionClosed) - Monitor sock(7fe620d0e610) 'Kodi' disconnected
2020-07-12 09:22:57.006678 N [16271/17667] Scheduler scheduler.cpp:3400 (ShutdownServer) - Running the command to set the next scheduled wakeup time :-
				sudo pmset schedule wake "07/12/20 10:15:00"
2020-07-12 09:22:57.203499 N [16271/17667] Scheduler scheduler.cpp:3431 (ShutdownServer) - Running the command to shutdown this computer :-
				sudo pmset sleepnow

...

2020-07-12 09:23:15.050301 N [16271/17667] Scheduler scheduler.cpp:3246 (HandleIdleShutdown) - I'm idle now... shutdown will occur in 600 seconds.
2020-07-12 10:15:02.213759 N [16271/17923] Expire autoexpire.cpp:251 (CalcParams) - AutoExpire: CalcParams(): Max required Free Space: 1.0 GB w/freq: 15 min

...

2020-07-12 10:15:19.538572 I [16271/17667] Scheduler scheduler.cpp:3299 (CheckShutdownServer) - CheckShutdownServer returned - OK to shutdown
2020-07-12 10:15:19.538725 N [16271/17667] Scheduler scheduler.cpp:3400 (ShutdownServer) - Running the command to set the next scheduled wakeup time :-
				sudo pmset schedule wake "07/12/20 10:15:00"
2020-07-12 10:15:19.657483 N [16271/17667] Scheduler scheduler.cpp:3431 (ShutdownServer) - Running the command to shutdown this computer :-
				sudo pmset sleepnow

...

2020-07-12 10:16:43.700526 I [16271/194563] ProcessRequest mainserver.cpp:1743 (HandleAnnounce) - MainServer: adding: Kodi(7fe6238b07c0) as a client (events: 1)
2020-07-12 10:25:17.319736 E [16271/191495] HDHRStreamHandler recorders/hdhrstreamhandler.cpp:471 (TunerSet) - HDHRSH(1230CA20-1): Set request failed
			eno: Resource temporarily unavailable (35)

Any ideas?

Thanks!

Re: Myth Shutdown Shortly After Waking

Posted: Sun Jul 19, 2020 10:51 am
by MoisiePants
Has no-one else had this issue? Guess I'll have to dive into the code to see what's happening.

Re: Myth Shutdown Shortly After Waking

Posted: Sun Jul 19, 2020 6:04 pm
by pgbennett
It looks like it was awake at 10:15 as it was supposed to. I suspect that you may have something in the GUI that is set to sleep on idle. You may need to disable the normal sleep on idle in the system (power manager settings or similar - set to never suspend).

Re: Myth Shutdown Shortly After Waking

Posted: Sun Jul 19, 2020 6:19 pm
by MoisiePants
Hi

Thanks for the reply - much appreciated.

All system sleep settings are turned off. The thing that puzzles me is that - as you say - it woke up at 10:15 as it was supposed to, but then 19 seconds later, the Myth shutdown process ran again:

Code: Select all

2020-07-12 10:15:19.538572 I [16271/17667] Scheduler scheduler.cpp:3299 (CheckShutdownServer) - CheckShutdownServer returned - OK to shutdown
2020-07-12 10:15:19.538725 N [16271/17667] Scheduler scheduler.cpp:3400 (ShutdownServer) - Running the command to set the next scheduled wakeup time :-
				sudo pmset schedule wake "07/12/20 10:15:00"

It's as though the shutdown got called twice - but the second one didn't get processed until after it had woken up from the first time, sending it to sleep again - but with a scheduled wakeup time in the past.

Re: Myth Shutdown Shortly After Waking

Posted: Sun Jul 19, 2020 7:54 pm
by pgbennett
I agree this is not reasonable. I think this behavior results from sleeping the server rather than shutting down. The backend expects to be shut down and then restarted after the wake up time. If you add a restart of the backend to your suspend script it should solve this problem. instead of sudo pmset sleepnow, create a script that stops the backend, sleeps, then starts the backend.

Re: Myth Shutdown Shortly After Waking

Posted: Mon Jul 20, 2020 6:59 am
by MoisiePants
Ah right - I see. Ok - I'll look into that then.

Thanks!

Re: Myth Shutdown Shortly After Waking

Posted: Wed Jun 23, 2021 6:02 pm
by pgbennett
Since the original answer I have set up a backend that sleeps instead of shutting down. I have not had the described problem. I have many checks in the pre-shutdown-check script and something there may be returning a non-zero code to prevent shutdown right after startup. You could put something in there to detect and prevent the condition.