-
-
Notifications
You must be signed in to change notification settings - Fork 911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Power] Implemented power-up/down functionality #388
base: master
Are you sure you want to change the base?
Conversation
While I don't argue this can be useful, I may suggest that unless tvheadend is the only function that needs to wakeup/sleep the device this is not the right place to take this sleep/restore decision: it should be a centralized and tvheadend being only a client. If other software programs the RTC (or even if something is programed directly in the BIOS) it may well screw up the other wakeup |
@EricV Do you know a deamon under linux which does this? I don't. And I agree this would be the most useful approach. Maybe I should talk to the systemd guys... ;-)
And if you look at all the other PVR solutions (vdr, mythtv) all of them are offering a similar functionality implemented in the same way. |
@schreibubi funnily enough I do, having hacked on an earlier version, powernapd. Unfortunately there was a difference of opinion and also I stopped suspending my server. But I've suggested integration into this before. |
Well for long I planned to write a small one but given the time I have to effectively program something it never really started. My idea was to reuse the scheduling recording database code from tvhreadend and transform it to a activity period database and add various interface to it to be able to program it via a browser, a socket or a qt client and then use rtcwake code from util-linux to program the clock. |
@EricV, @adamsutton Yeah would be nice to have such a daemon, but I neither have the time to implement this or extend an existing daemon. Looking a powernapd it seems to only support shutdown on detecting idle, but no programming of the wake-up time. I also wouldn't like to tightly integrate tvheadend with one specific daemon, but only provide all the required interfaces and let the user choose the solution he likes best. I currently see two scenarios which would need to be supported, which differ who is the master for programming the rtc and executing the shutdown.
So the only thing missing in my patch would be to implement an additional script which is called when the idle status of tvheadend changes. What do you think? Any other issues you have seen regarding my patch? |
It is not because a program is idle at the time you look at it that it can be shut down for unknwon period of time or you have to know know exactly how the entire programs set running on the machine behaves. Think about a DMS for example. It usually sleeps unless someone ask for accessing recordings but must send ssdp:alive periodically to be discovered asynchronuously. A bittorrent cleint will also need to maintain UPnP IGD ports open even when idle (on a NAS). Then going to sleep is one thing but you expect to wake up to see your recordings unless you record them on another device (not the usual case). There is a bunch of things you might need to program (USB wakeup for mouse, keyboard, remote, wol feature for ethernet, wonwl for WiFi). So if you plan tvheadend to be the master, please add a script that should cover all theses and enable wakeup on events. See /usr/share/doc/pm-utils/README.debugging for an idea about the complexity. |
If you want such sophisticated power management, then tvheadend should be the slave. But IMHO 90% of your users will not need this. Then the solution where tvheadend is the master is sufficient (as you can see from all the other vdrs using that solution). For me it is enough to wake my Server through wol. By using the scripts every user can adapt the fuctionality to suit his use case. What is wrong about that? |
Don't get me wrong: there nothing I really dislike and I even agree it is useful for many use cases. I just wanted to highlight the difficulties you may introduce for people when enabling this function:
So make sure:
|
embedded users would hate you for this. you know. sudo, bash-isms.. |
@stefansaraev The bash-isms I can avoid, but sudo? What do you propose to use instead? On my server tvheadend runs as a seperate user, so I need sudo to execute the shutdown. |
dunno, this is a grey area and you know that. why not talk to systemd (logind) via dbus ? my point is: a feature that works for you (or requires a specific distro / tools installed) is worthless if the world (other people / distros) can't benefit :) EDIT: and there are the BSDs (tvheadend do support *bsd), so they might hate you too ;) |
@stefansaraev Systemd, dbus for embedded systems? NAS that still runs on ARM have seldom real WOL on S5, no ACPI usually. And just to correct your sentence, systemd has already landed in Debian unstable. rtcwake is in util-linux but more problematic most of the suspend/resume/wakeup is mostly based on ACPI nowadays and thus Intel. |
Just to throw in my 2 pence, personally I don't like this feature (at least not in the general sense). Although I can understand that for someone running a dedicated, single app, server for TVH, they might wish to have it responsible for power management. This is not the norm, most users probably run TVH or a shared box that's doing a bunch of different things (in my case, it's my file server and a few other things). Personally I believe power management should be managed by a dedicated power manager (such as powernapd). Having hooks that can call user defined routines, or visa versa (scripts in pwrmgr that can interface into TVH) is fine, but no more than that. Adam |
@EricV exactly! :) I was about to write just the same as @adamsutton did ^ |
Just to add my own thoughts into this, I implemented something vaguely similar into mine, however I did it externally to TVH as I didn't think it was 'part' of TVH itself. I used the API/status page in the init scripts to determine current TVH activity and then take action appropriately. As mentioned above, I think this is the clearer way forward rather than modfying tvh to have any form of system/power management. Again, probably just my point of view+thoughts. |
@fda77 : use dbus interface - there is dvr next time signal.. you may use support/dbus_test.py to show these signals.. adding this value to the post-processor script is the bad idea because this value can be changed anytime (when user changes the dvr schedule) |
b30f05b
to
1bd1564
Compare
This might be dead now, but FYI, the terminology this feature is called "real-time clock alarm" when talking about the standard computer BIOS/UEFI functionality which is built-into most computers based on ACPI BIOS or UEFI and have a RTC (Real-Time Clock). https://en.wikipedia.org/wiki/Real-time_clock_alarm The feature is also often refered to as WoRTC (Wake on RTC) or WOT (Wake-On-Time), the latter abbreviation WOT I believe was chosen because it follow a similar name-standard to WOL (Wake-On-LAN). Btw, I think that this is a very nice DVR set-top box appliance-like function to have for a PVR software like Tvheadend, and it is also a feature which is available in MythTV, see: http://www.mythtv.org/wiki/ACPI_Wakeup |
1be30a3
to
8a7348b
Compare
c193390
to
9ca5166
Compare
Just for the record and probably years too late:
This idea was taken into account for the development of git-developer/autosuspend and languitar/autosuspend. |
Implement all the required functionalities to shut-down the tvheadend server when it is idle and restart the tvheadend server before an upcoming recording.