Service to get SHUTDOWN_COUNTDOWN?
Service to get SHUTDOWN_COUNTDOWN?
Is there a programatic way for a script to get myth's shutdown countdown? (The value you see at the top of mythwelcome when the system is idle and it's going to shut down when the countdown reaches zero.)
Re: Service to get SHUTDOWN_COUNTDOWN?
No (that was easy.) You might mention your use case and see if anyone has another
solution. This could be of interest: https://www.mythtv.org/wiki/Myth_Service#DelayShutdown
solution. This could be of interest: https://www.mythtv.org/wiki/Myth_Service#DelayShutdown
Re: Service to get SHUTDOWN_COUNTDOWN?
Use case:
I want to run a background queue processor (not mythtv jobs, completely external) that will process jobs whenever the system is on, and either the backend is busy or the frontend is being actively used.
If backend is not busy, mythshutdown -c still returns "OK to shutdown" even if the frontend is still being used. I want to continue processing jobs in this state.
But I can't just check for the existence of a mythfrontend process, as there is an idle timeout setting. (I know this can be disabled.) So I need to find a way to know when frontend enters standby to stop processing jobs.
I would still lock before and unlock after a job, and if necessary wait some period between jobs to allow checking for "true idle" (both backend and frontend.)
I basically want to put jobs in a queue that may take several wakeup/shutdown cycles to complete, without forcing the system to stay on until my queue is empty.
Specifically, this is a transcoding queue using HandBrakeCLI. I have all the parts working and have been running it for small batches of jobs when I know the machine is going to be on for a while.
So I need a way to detect either:
- shutdown timer in progress
- frontend entered standby
or anything that would serve the same function.
I want to run a background queue processor (not mythtv jobs, completely external) that will process jobs whenever the system is on, and either the backend is busy or the frontend is being actively used.
If backend is not busy, mythshutdown -c still returns "OK to shutdown" even if the frontend is still being used. I want to continue processing jobs in this state.
But I can't just check for the existence of a mythfrontend process, as there is an idle timeout setting. (I know this can be disabled.) So I need to find a way to know when frontend enters standby to stop processing jobs.
I would still lock before and unlock after a job, and if necessary wait some period between jobs to allow checking for "true idle" (both backend and frontend.)
I basically want to put jobs in a queue that may take several wakeup/shutdown cycles to complete, without forcing the system to stay on until my queue is empty.
Specifically, this is a transcoding queue using HandBrakeCLI. I have all the parts working and have been running it for small batches of jobs when I know the machine is going to be on for a while.
So I need a way to detect either:
- shutdown timer in progress
- frontend entered standby
or anything that would serve the same function.
Re: Service to get SHUTDOWN_COUNTDOWN?
I just did some testing and noted that mythfrontend logs a message when it enters standby mode, and another when it leaves. So if nothing else, I can monitor the log.
Re: Service to get SHUTDOWN_COUNTDOWN?
You can easily check if the frontend is idle by using the network control port. Enable network control in the frontend setup. Send a message to port 6546 "query location" and if it returns "standbymode" it is in standby mode. For example:
You can test the network control port using telnet to see what it sends.
However I would recommend rather handle this by adding some checks to the mythtv pre-shutdown-check command to prevent shutdown while HandBrakeCLI is running. For example:
Code: Select all
if pidof mythfrontend ; then
fstate=`( sleep 1 ; echo query location ; sleep 1 ; echo quit ) \
| nc localhost 6546 | grep "#" | head -1 | sed "s/# //" \
| dos2unix`
if [[ "$fstate" != standbymode ]] ; then
...
fi
fi
However I would recommend rather handle this by adding some checks to the mythtv pre-shutdown-check command to prevent shutdown while HandBrakeCLI is running. For example:
Code: Select all
encoders='HandBrakeCLI|ffmpeg|avidemux3_cli'
if ps -ef|egrep "$encoders"|egrep -v "grep " ; then
echo $DATE "encoders are running, don't shut down for 5 min."
rc=1
fi
exit $rc
Re: Service to get SHUTDOWN_COUNTDOWN?
Thanks! I'll check that out.
However, I'm also going to check if the Frontend service call GetStatus will tell when frontend is in standby mode.
At first glance, that appears to be the opposite of what I want to do. I don't want to keep myth on while I have jobs, I want jobs to pause when myth wants to shut down.
However, what you suggest could still be added as a "safety," for transcoding jobs and any other non-mythtv process I don't want to be interrupted by shutdown. I'll check it out.
Re: Service to get SHUTDOWN_COUNTDOWN?
http://localhost:6547/Frontend/GetStatus returns "standbymode" for "currentlocation" when in standby mode.