Gotham with a backend that is configured for wake on lan and idle shutdown
#1
Hi,

I have been doing to some work to get XBMC Gotham and the cmyth pvr plugin to work the same way they used to work with my mythtv backend using Frodo.

My backend is configured for wake on lan and for automatic shutdown when idle. At Frodo I used the AdvancedWakeOnLan program add-on to wake the backend when xbmc started. Nothing else was required as the backend would not shutdown until all my clients had disconnected.

When I moved to Gotham I noticed that whilst AdvancedWakeOnLan brought the backend up as expected, it would soon shutdown again if the xbmc frontend was not actually interacting with the backend e.g. playback. In this situation the only way to get things going again was to rerun the AdvancedWakeOnLan add-on.

I had a look at the latest cmyth pvr stuff and discovered that there was some WOL stuff builtin. However I soon discovered that this would not wake the backend and was only designed to handle wakeup of the backend after a suspend and resume of the frontend.

I have made some code changes to make the cmyth pvr plugin also handle wakeup of the backend from cold, and from a backend idle shutdown.

You can find these minimal changes here

https://github.com/rogerjames99/xbmc-pvr...d62af0a9c2

I would really like to stop the backend doing an idle shutdown whilst xbmc was connected in the same way as it did in Frodo. However it looks like the version of cmyth used does not do this. A newer version of the cmyth library is in fact required to reinstate this functionality, that is too much work for me at the moment.

I would also like to point out the myth web services api is also not protected from a server idle shutdown so the same problem will exist web the new web service based mythtv plugin. I would suggest that easiest way to fix this in the new plugin is to open a cmyth connection (using the latest library) as well and issue a block shutdown command on it.

Feel free to clone my repo to try this out.

When I have run this for a while I will ask for this to be pulled into the main respository.

Roger
Reply
#2
Hi Roger,

So we choosen to not use "block shutdown" for some reasons explained below.
- It Prevents a backend from shutting down until a the next call to ALLOW_SHUTDOWN. So you have to call protocol command "ALLOW_SHUTDOWN" on any announcement of XBMC: stopping, sleeping etc... else configuring idle shutdown is useless.
- If you break XBMC client your backend still blocking and never shutting down => configuring idle shutdown is useless.

So the way we choosen is to let backend shutting down. If XBMC still up, meaning not sleep or not broken or not stopped, then we send WOL when backend is disconnected. You have to configure the idle time large enough to avoid shutdown just after startup. Probably at least 2 hours.

It would be possible to use block/allow shutdown call. To do:
- We have to add a new setting to enable it for users want only. Because lot would prefer to keep current behavior.
- We have to handle XBMC annoucements to allow shutdown.
- You have to know your backend never shutting down after break of client (forced switch-off, crash etc..)

This new behavior can be added to the new addon "pvr.mythtv". Let me know.
Reply
#3
What else,
In the frodo version of the addon, i used a "playback" connection to control the backend. It was the reason why backend never shutdown until stopping XBMC. But it was a bug and users wanted a fix to allow backend sleep or stop. I fixed it with gotham version using a "monitor" connection instead like mythfrontend done.
So the only way to make the behavior you want is to handle XBMC announcements and block or allow shutdown. And this behavior have to be enabled by a special setting.
Reply
#4
Finally, cmyth lib is obsolete and as i said in other thread i do no longer want to maintain it for different reasons exposed below:
- Since 0.27 MythTV provides a clean way to access content and schedule recording: soap/json api.
- Soon MythTV will change the database structure. So hacking the database like cmyth does is not sustainable.

The new lib cppmyth doesn't hack database and use only services provided by MythTV interfaces: web/json and protocol. Using it we can support the current 0.27 and next releases of MythTV.
Reply
#5
You can configure the back end to not suspend via the myth-shutdown-check script functionality, by pinging the frontend. No reply from the ping and the back end is OK to suspend.
Reply
#6
You now have me really confused. I have checked out your new code and looked at it. I admit that I only looked at the bottom (network) very briefly as that was not what I was really interested in at the time; I was looking for shutdown wakeup related stuff.

I cannot look at the code again at the moment, but it looked to me like it was still sending out old style myth protocol encoded messages over a raw TCP connection to the standard myth protocol port.

I saw no evidence of the myth web services protocol which is a SOAP/JSON encoded protocol carried over an https connection to a standard web server port on the myth server.

Am I being really stupid and missing something fundamental here. I will not mind or get upset if you tell me I am.

Roger

Sorry missed/crossed your last post. Too tired to reply now.

Also missed the fact that it wasn't from you janbar
Reply
#7
OK I am stupid or blind or both. I have no idea what I was looking at before. But I have looked at the code after some sleep and found the json stuff straight away.

Mea Culpa.
Reply
#8
OK it is later now. So my patches and comments have definitely no relevance to the new pvr.mythtv plugin.

But can I plead with you guys to persuade opdenkamp to let the patches into the current pvr.mythtv.cmyth source. If only for the entirely selfish reason that it will save me the huge hassle of doing an openelec source build :-). It might persuade anyone who has problems with them to move to your new plugin :-). I will even offer to make them conditional if that helps.
Reply
#9
The openelec build proved a lot easier than I thought so I will delete the pull requests and leave you guys in peace.
Reply
#10
OK I have been running my code on my openelec system for a while now, it seems to work OK and removes the need to run the AdvancedWakeOnLan add-on.

The code can be found at https://github.com/rogerjames99/xbmc-pvr-addons

You can use the compare tool there (next to the pull request tool) to view the minimal changes I have made to the base. If anyone wants to try an openelec generic build with these changes in I will put a openelec generic x86_64 tar up on Dropbox on request, be warned it is 151Mb. I will answer questions about my code changes only not end user questions about how to install openelec/xbmc development builds etc!

Roger
Reply

Logout Mark Read Team Forum Stats Members Help
Gotham with a backend that is configured for wake on lan and idle shutdown0