[Solved] Mythwelcome cannot shut down computer

Have a MythTV related problem? Ask for help from other MythTV users here.

Moderator: Forum Moderators

Post Reply
linuxguy1454
Newcomer
Posts: 12
Joined: Fri Jun 14, 2019 9:10 pm
Location: Northern California
United States of America

[Solved] Mythwelcome cannot shut down computer

Post by linuxguy1454 » Sat Jun 15, 2019 12:39 am

I cannot get mythwelcome to shutdown the computer on a new Myth installation, I assume this is because the status is always reporting "MythTV is locked by a user" but I haven't been able to figure out why it is always locked when I don't have any other apps running.

Going to the menu via 'M' then selecting 'Unlock Shutdown' doesn't affect it at all.

Every 30 seconds in mythshutdown.log I'm getting "E CoreContext main.cpp:277 (getStatus) Shutdown is locked" and "I CoreContext main.cpp:369 (getStatus) Mythshutdown: --status returned: 16" which just confirms what I am seeing.

Frontend and backend are running fine, I can record and watch recordings.

My user account is set for autologin in /etc/lightdm/lightdm.conf and I have mythwelcome set to autolaunch in ~/.config/autostart/mythwelcome.desktop (Exec=/usr/bin/mythwelcome). I launch mythfrontend from mythwelcome manually.

Is there something wrong with this setup? Let me know if I need to post additional information, such as the list of running processes owned by my login, if that would help.

Thanks for any suggestions.
Last edited by Steve Goodey on Mon Jun 17, 2019 6:03 am, edited 1 time in total.
Reason: Added (Solved) to title.
MythTV v29.1-13-g329c235, fixes/29, Library API : 29.20180316-1
with HDHR3 tuner on Ubuntu 18.04 Bionic Beaver and lightdm.

User avatar
bill6502
Developer
Posts: 1724
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Mythwelcome cannot shut down computer

Post by bill6502 » Sat Jun 15, 2019 1:08 am

The MythShutdownLock is not 0. Try: mythshutdown --unlock

It's a counter, it may not simply = 1 . curl yourBackendHostNameOrIP:6544/Myth/GetSetting?Key=MythShutdownLock\&HostName=_GLOBAL_
will show its value.

linuxguy1454
Newcomer
Posts: 12
Joined: Fri Jun 14, 2019 9:10 pm
Location: Northern California
United States of America

Re: Mythwelcome cannot shut down computer

Post by linuxguy1454 » Sat Jun 15, 2019 2:36 am

Thanks for the info Bill, I tried mythshutdown --unlock a few times, no change. But I'm doing that from a terminal window which should prevent a shutdown. I tried the URL http://[my IP address]:6544/Myth/GetSetting?Key=MythShutdownLock\&HostName=_GLOBAL but I only get
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<String/>
and no value to be seen. I forgot to mention this is a frontend-backend combined machine, everything is local. I did check netstat -nao | grep :6544 and got
tcp 0 0 0.0.0.0:6544 0.0.0.0:* LISTEN off (0.00/0/0)
tcp6 0 0 [::]:6544 [::]:* LISTEN off (0.00/0/0)
Am I doing something wrong to show the counter value? I'm not aware of doing anything except mythshutdown --unlock to affect the counter.

I will close this browser so that only mythwelcome is running. If anything changes, I'll post an update.
MythTV v29.1-13-g329c235, fixes/29, Library API : 29.20180316-1
with HDHR3 tuner on Ubuntu 18.04 Bionic Beaver and lightdm.

User avatar
bill6502
Developer
Posts: 1724
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Mythwelcome cannot shut down computer

Post by bill6502 » Sat Jun 15, 2019 2:51 am

I dropped the trailing _ after _GLOBAL (fixed it), plus if run from a browser, leave off the backslash
before the ampersand (it's there to avoid spinning off the command in the shell.)

User avatar
paulh
Developer
Posts: 544
Joined: Thu Feb 06, 2014 6:09 pm
Great Britain

Re: Mythwelcome cannot shut down computer

Post by paulh » Sat Jun 15, 2019 12:11 pm

Code: Select all

mythshutdown --check
will also tell you the current status of the lock. If you see 'Shutdown is locked Not OK to shutdown' then keep calling

Code: Select all

mythshutdown --unlock 
until you see 'OK to shutdown'. You may see other things blocking shutdown like mythfilldatabase is running or mythcommflag is running or recording etc.

linuxguy1454
Newcomer
Posts: 12
Joined: Fri Jun 14, 2019 9:10 pm
Location: Northern California
United States of America

Re: Mythwelcome cannot shut down computer

Post by linuxguy1454 » Sun Jun 16, 2019 3:45 am

I'm back to look at this again. The URL [my_ip]:6544/Myth/GetSetting?Key=MythShutdownLock&HostName=_GLOBAL_ gives me a count of 38 in Firefox and 15 in chromium. Then running mythshutdown --unlock a dozen times then refreshing the web pages or newly pasting in the URL still reports 38 in FF and 15 in chrome.

I thought that the idea of mythwelcome was to only shut down the machine when it was idle and not to shut down if you are using the desktop, such as an xterm, browser, etc. Doesn't doing all this testing with a browser and terminal always qualify as keeping the system active?

My ultimate goal is to use ACPI wakeup, which I have verified to work on my box (HP Z210 desktop), to wake up the machine for the next recording if I don't power on to watch something. But first I think I need to get it to be idle so that it can shut down. And I shouldn't have to teach other members of the household to open up an xterm and run shutdown.

Thanks for the help so far. Any other suggestions?
MythTV v29.1-13-g329c235, fixes/29, Library API : 29.20180316-1
with HDHR3 tuner on Ubuntu 18.04 Bionic Beaver and lightdm.

linuxguy1454
Newcomer
Posts: 12
Joined: Fri Jun 14, 2019 9:10 pm
Location: Northern California
United States of America

Re: Mythwelcome cannot shut down computer

Post by linuxguy1454 » Sun Jun 16, 2019 4:04 am

Hit the URL from my laptop and got a 0, so I logged out of my TV user and let it autologin and autostart mythwelcome. The status is now idle, no recordings currently taking place, and next schedulted recording is next Thursday. Logged in via SSH and the only myth things running are the backend and mythwelcome. I'll give it the 15 minutes to shutdown on its own.
MythTV v29.1-13-g329c235, fixes/29, Library API : 29.20180316-1
with HDHR3 tuner on Ubuntu 18.04 Bionic Beaver and lightdm.

linuxguy1454
Newcomer
Posts: 12
Joined: Fri Jun 14, 2019 9:10 pm
Location: Northern California
United States of America

Re: Mythwelcome cannot shut down computer

Post by linuxguy1454 » Sun Jun 16, 2019 5:35 am

Just sitting there idle. Tomorrow I will have to see if there is anything in the logs.
MythTV v29.1-13-g329c235, fixes/29, Library API : 29.20180316-1
with HDHR3 tuner on Ubuntu 18.04 Bionic Beaver and lightdm.

User avatar
paulh
Developer
Posts: 544
Joined: Thu Feb 06, 2014 6:09 pm
Great Britain

Re: Mythwelcome cannot shut down computer

Post by paulh » Sun Jun 16, 2019 10:33 am

I would ignore that URL Bill gave you I think what you are seeing is the BE caches the settings so what you get back is the old cached value. The status returned by mythshutdown is always correct since it read/writes the value direct from the database.

User avatar
bill6502
Developer
Posts: 1724
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Mythwelcome cannot shut down computer

Post by bill6502 » Sun Jun 16, 2019 2:55 pm

Paul's right, but it's the backend sending the same ETag even if the value changed,
so any browser that returns ETags and gets a 304. It's a backend bug (that
was fixed in v31-Pre on 2019-06-18.)

User avatar
dizygotheca
Developer
Posts: 267
Joined: Wed Sep 03, 2014 9:02 am
Great Britain

Re: Mythwelcome cannot shut down computer

Post by dizygotheca » Sun Jun 16, 2019 5:07 pm

I thought that the idea of mythwelcome was to only shut down the machine when it was idle and not to shut down if you are using the desktop, such as an xterm, browser, etc. Doesn't doing all this testing with a browser and terminal always qualify as keeping the system active?
No, the backend will attempt to shutdown the machine when Myth is idle; it has no concept of the machine being idle.
Myth is idle when the backend isn't doing anything and all frontends have disconnected.
Originally the only way for frontends to disconnect was for them to exit. However that's a one-way ticket and the backend status couldn't be displayed afterwards. Automatically starting a frontend during unattended recordings also prevented shut down. MythWelcome filled that hole by showing a screen during the state of 'backend is running but this frontend isn't'.

What Myth version ? For a long time the frontend has contained an "Idle Screen" that duplicates MythWelcome functionality making it obsolete.
https://www.mythtv.org/wiki/Idle_Screen

I think mythshutdown also runs the "Pre Shutdown check-command" script https://www.mythtv.org/wiki/Setup_Gener ... up_Options
That's the (user-defined) place to block shutdown if the desktop is in use, someone is logged in etc.
Do you have something configured there that is always blocking shutdown ?

mythbackend -v system --loglevel debug
should show more detail of where it is blocking

Note the scripts on https://www.mythtv.org/wiki/ACPI_Wakeup are fragile and behave differently on different OS/versions.

User avatar
paulh
Developer
Posts: 544
Joined: Thu Feb 06, 2014 6:09 pm
Great Britain

Re: Mythwelcome cannot shut down computer

Post by paulh » Sun Jun 16, 2019 9:38 pm

How it used to work is you would set mythshutdown --check as the "Pre Shutdown check-command". It does checks like see if the BE is busy recording, mythtranscode is running a job, mythfilldatbase is running, mythcomflag is running, we are about to start recording, shutdown has been locked (ie mythshutdown --lock has been called) etc.

There's been a case of too many cooks meddling with it and so the original concept of mythwelcome and mythshutdown has become a little confused so who knows how it is supposed to work now.

linuxguy1454
Newcomer
Posts: 12
Joined: Fri Jun 14, 2019 9:10 pm
Location: Northern California
United States of America

[Solved] Mythwelcome cannot shut down computer

Post by linuxguy1454 » Mon Jun 17, 2019 4:18 am

Thanks everybody for chiming in. I discovered an incorrect shutdown command in mythtv-setup. On the Backend Control page, which I had not visited before (partly because it was scrolled off the bottom of the displayed list), the Stop command was set to

Code: Select all

sudo sv stop mythbackend
Start was set to

Code: Select all

sudo sv start mythbackend
These must have been default settings in fixes/29 that I'm running. (Full disclosure: I originally installed Mythbuntu 16.04 then upgraded to Ubuntu 18.04. I only realized after this upgrade that there is no Mythbuntu 18.04.) I changed the 2 commands to

Code: Select all

sudo /etc/init.d/mythtv-backend stop
and start respectively.

On the test I ran a few hours ago, it shut down as expected!! I will do some more testing for various combinations of activity vs. idle state, and for ACPI wakeup. Since it did shutdown, I'm changing the topic as solved (not sure if I'm doing that correctly). Thanks again for the help.
MythTV v29.1-13-g329c235, fixes/29, Library API : 29.20180316-1
with HDHR3 tuner on Ubuntu 18.04 Bionic Beaver and lightdm.

User avatar
Steve Goodey
Moderator
Posts: 115
Joined: Fri Feb 07, 2014 6:30 pm
Location: Colchester, England
Great Britain

Re: [Solved] Mythwelcome cannot shut down computer

Post by Steve Goodey » Mon Jun 17, 2019 6:08 am

I'm changing the topic as solved (not sure if I'm doing that correctly).
Hi, you needed to change the subject in the first post to get [Solved] to show in the forum topic list. I've done that for you. :-)

linuxguy1454
Newcomer
Posts: 12
Joined: Fri Jun 14, 2019 9:10 pm
Location: Northern California
United States of America

Re: [Solved] Mythwelcome cannot shut down computer

Post by linuxguy1454 » Mon Jun 17, 2019 6:44 pm

Thanks Steve.

I think what fixed it was changing the check command from checklogin.sh that I found in the Wiki to /usr/bin/mythshutdown --check. Not only is the check working and shutting down the system when it is idle, my ACPI setup is working! Great to have this working now. I never could get it working on my previous installations on different hardware and earlier versions of mythtv.
MythTV v29.1-13-g329c235, fixes/29, Library API : 29.20180316-1
with HDHR3 tuner on Ubuntu 18.04 Bionic Beaver and lightdm.

Post Reply