PDA

View Full Version : SrvrPowerCtrl - End of Day action



rickwookie
2009-08-04, 11:06
Does SrvrPowerCtrl wake up a sleeping server to execute the End of Day action (which in my case is to shut it down again)?

The reason I ask is that my server keeps waking at midnight and it's definately being set from the plugin:

Sat Aug 1 00:41:04 BST 2009: /usr/bin/scwakeup.sh 1249110300
Setting /sys/class/rtc/rtc0/wakealarm to 1249110300 (2009-08-01 07:05:00)
Sat Aug 1 17:52:00 BST 2009: /usr/bin/scwakeup.sh 1249171200
Setting /sys/class/rtc/rtc0/wakealarm to 1249171200 (2009-08-02 00:00:00)
Sun Aug 2 00:41:03 BST 2009: /usr/bin/scwakeup.sh 1249257600
Setting /sys/class/rtc/rtc0/wakealarm to 1249257600 (2009-08-03 00:00:00)
Sun Aug 2 12:46:21 BST 2009: /usr/bin/scwakeup.sh 1249257600
Setting /sys/class/rtc/rtc0/wakealarm to 1249257600 (2009-08-03 00:00:00)
Sun Aug 2 19:21:51 BST 2009: /usr/bin/scwakeup.sh 1249257600
Setting /sys/class/rtc/rtc0/wakealarm to 1249257600 (2009-08-03 00:00:00)
Mon Aug 3 00:41:04 BST 2009: /usr/bin/scwakeup.sh 1249283100
Setting /sys/class/rtc/rtc0/wakealarm to 1249283100 (2009-08-03 07:05:00)
Mon Aug 3 12:47:49 BST 2009: /usr/bin/scwakeup.sh 1249344000
Setting /sys/class/rtc/rtc0/wakealarm to 1249344000 (2009-08-04 00:00:00)
Mon Aug 3 22:31:50 BST 2009: /usr/bin/scwakeup.sh 1249344000
Setting /sys/class/rtc/rtc0/wakealarm to 1249344000 (2009-08-04 00:00:00)
Tue Aug 4 00:41:02 BST 2009: /usr/bin/scwakeup.sh 1249369500
Setting /sys/class/rtc/rtc0/wakealarm to 1249369500 (2009-08-04 07:05:00)
but I can't see why.

gharris999
2009-08-04, 11:27
Does SrvrPowerCtrl wake up a sleeping server to execute the End of Day action (which in my case is to shut it down again)?

The reason I ask is that my server keeps waking at midnight and it's definately being set from the plugin:

Sat Aug 1 00:41:04 BST 2009: /usr/bin/scwakeup.sh 1249110300
Setting /sys/class/rtc/rtc0/wakealarm to 1249110300 (2009-08-01 07:05:00)
Sat Aug 1 17:52:00 BST 2009: /usr/bin/scwakeup.sh 1249171200
Setting /sys/class/rtc/rtc0/wakealarm to 1249171200 (2009-08-02 00:00:00)
Sun Aug 2 00:41:03 BST 2009: /usr/bin/scwakeup.sh 1249257600
Setting /sys/class/rtc/rtc0/wakealarm to 1249257600 (2009-08-03 00:00:00)
Sun Aug 2 12:46:21 BST 2009: /usr/bin/scwakeup.sh 1249257600
Setting /sys/class/rtc/rtc0/wakealarm to 1249257600 (2009-08-03 00:00:00)
Sun Aug 2 19:21:51 BST 2009: /usr/bin/scwakeup.sh 1249257600
Setting /sys/class/rtc/rtc0/wakealarm to 1249257600 (2009-08-03 00:00:00)
Mon Aug 3 00:41:04 BST 2009: /usr/bin/scwakeup.sh 1249283100
Setting /sys/class/rtc/rtc0/wakealarm to 1249283100 (2009-08-03 07:05:00)
Mon Aug 3 12:47:49 BST 2009: /usr/bin/scwakeup.sh 1249344000
Setting /sys/class/rtc/rtc0/wakealarm to 1249344000 (2009-08-04 00:00:00)
Mon Aug 3 22:31:50 BST 2009: /usr/bin/scwakeup.sh 1249344000
Setting /sys/class/rtc/rtc0/wakealarm to 1249344000 (2009-08-04 00:00:00)
Tue Aug 4 00:41:02 BST 2009: /usr/bin/scwakeup.sh 1249369500
Setting /sys/class/rtc/rtc0/wakealarm to 1249369500 (2009-08-04 07:05:00)
but I can't see why.

Yes, SrvrPowerCtrl treats the EOD action just like an alarm and will wake the server for it. If this is undesirable, I suppose that there are two approaches we could take:

1). Provide a check-box option in the settings to specifically "opt-in" for EOD wakeup.

--or--

2). Only schedule EOD wakeup if the EOD action is set to a custom script.

Which makes more sense to you? Or do you have another idea?

rickwookie
2009-08-07, 06:59
Yes, SrvrPowerCtrl treats the EOD action just like an alarm and will wake the server for it. If this is undesirable, I suppose that there are two approaches we could take:

1). Provide a check-box option in the settings to specifically "opt-in" for EOD wakeup.

--or--

2). Only schedule EOD wakeup if the EOD action is set to a custom script.

Which makes more sense to you? Or do you have another idea?

Yeah I though of exactly those two options too!

After thinking some more about it, obviously it's only worth waking for the EOD action if it's custom (so not just to shut it down again) but ultimately there are custom actions that may also be irrelevant for a shutdown system, so the extra checkbox gives ultimate flexibilty while not wasting power (and hdd wear, etc.) to wake just to wait 40 minutes and then shut down again. Maybe put it by the custom command text box as something like 'wake system to perform this action'.

gharris999
2009-08-07, 08:51
Yeah I though of exactly those two options too!

After thinking some more about it, obviously it's only worth waking for the EOD action if it's custom (so not just to shut it down again) but ultimately there are custom actions that may also be irrelevant for a shutdown system, so the extra checkbox gives ultimate flexibilty while not wasting power (and hdd wear, etc.) to wake just to wait 40 minutes and then shut down again. Maybe put it by the custom command text box as something like 'wake system to perform this action'.
The one non-custom action available in the drop-down list that, it seems to me, is worthy of a wake-up is the 'Restart Server' action. I know that some folks pride themselves on the fact that their linux servers have been up for years at a time without a reboot. I'm not one of them. I like to see my server rebooted once a day. But, certainly, that could be accomplished in a custom script.

My own custom EOD script updates the OS, updates a couple of different svn branches of SqueezeCenter code, reboots the server and then, shortly thereafter, a SC wipe-and-rescan gets initiated. So, all my chores get performed daily between 2 & 3 am.

Can you think of an example of a custom script action that wouldn't be worthy of a wake-up? If I can get away without having to add another pref, I'd prefer that.

Another tweak to the EOD behavior that I'm thinking of trying is this:

If the EOD idle timeout is set to zero, then the custom script gets executed just once within that EOD period. All other EOD idle invocations would ignore the custom script and fire the selected 'stock' action instead. This would allow the custom script to fire once and perform the big chores. Then, with SC restarted, the next EOD action could be a quick suspend. Thus the server would be awake for a shorter time for the chores.

This would suit my purposes, anyway. I'm just not sure I've thought through all the (potentially unintended) consequences here.

rickwookie
2009-08-09, 09:31
I think what my problem is is that I'm possible not using the EOD action for the purpose it was intended. I'm mearly using it as an aditional idle timer, but with a much shorter time out to the 'daytime' one.

During the day I want my server on most of the time, since I have to wait over a minute to start it (still can't get it to wake from S3). So I set the idle time-out to about three hours, so it only shuts down to SqueezeNetwork if I'm really not using it for a good while. However, it's unlikely that I'll want to play something at 1am unless it's a late night session or party, in which case the system won't be idle at that time. I use the EOD action to shut it down at night with a much shorter idle time-out (10 minutes I think) so that if I finish listening to music at midnight for example, the server won't waste energy hanging around until 3am to shutdown. It's for this reason that I don't want my shut-down server to wake at midnight.

Maybe the custom EOD action could be a completely different thing (that will be woken for, although I still tend to think that that should be an option), and instead you could put an 'Economy7' type mode in the standard idle timer so that the user could define two time periods with two different idle time-outs. Day and night prefs if you like.

gharris999
2009-08-10, 08:26
I think what my problem is is that I'm possible not using the EOD action for the purpose it was intended. I'm mearly using it as an aditional idle timer, but with a much shorter time out to the 'daytime' one.

During the day I want my server on most of the time, since I have to wait over a minute to start it (still can't get it to wake from S3). So I set the idle time-out to about three hours, so it only shuts down to SqueezeNetwork if I'm really not using it for a good while. However, it's unlikely that I'll want to play something at 1am unless it's a late night session or party, in which case the system won't be idle at that time. I use the EOD action to shut it down at night with a much shorter idle time-out (10 minutes I think) so that if I finish listening to music at midnight for example, the server won't waste energy hanging around until 3am to shutdown. It's for this reason that I don't want my shut-down server to wake at midnight.

Maybe the custom EOD action could be a completely different thing (that will be woken for, although I still tend to think that that should be an option), and instead you could put an 'Economy7' type mode in the standard idle timer so that the user could define two time periods with two different idle time-outs. Day and night prefs if you like.
No, no, your use is a perfect use for EOD and I agree that it ought function to serve your purposes exactly as you've described them. My attempt to make the EOD action function a couple of different ways...specifically to support the "end of day chores" model that I've described above, wasn't thought completely through.

Here's my proposed *initial* change:

At regualar idle time-out, SrvrPowerCtrl compares the EOD action setting against the pending regular idle action: if they are the same, then no wake-for-EOD will be scheduled. If, however, the EOD action is a custom script, or if it differs from the pending idle action, then wakeup for EOD will be scheduled. This much can be accomplished without having to add another pref setting and I think it should serve your purposes. The only limitation here is that you'll have to be careful to set the EOD action to equal the regular idle action to avoid EOD wakeup. If the regular idle action is set to suspend and the EOD action is set to hibernate, then wakeup will occur. I ought to have programmed it to function this way from the start. Thanks for prompting me on this.

I'll post here when I've got this code up and you can let me know if it serves your purpose.

rickwookie
2009-08-13, 02:23
As I was reading your last post I straight away thought of the issue where you might have a slightly different Sleep/Shutdown option for Idle vs EOD, but then just as quickly realised that if this was the cas, then you probably would still want the EOD action to 'wake-to-do'. If you are luck enough to have a box that could wake from Sleep, that might be your regular idle action, then for EOD it would wake from sleep (which would only take a couple of seconds' in order to shut down (or hibernate) properly.

So, yeah I think your logic is bang on there and I look forward to seeing it implemented.

Keep up the good work! :-)

gharris999
2009-08-14, 10:47
As I was reading your last post I straight away thought of the issue where you might have a slightly different Sleep/Shutdown option for Idle vs EOD, but then just as quickly realised that if this was the cas, then you probably would still want the EOD action to 'wake-to-do'. If you are luck enough to have a box that could wake from Sleep, that might be your regular idle action, then for EOD it would wake from sleep (which would only take a couple of seconds' in order to shut down (or hibernate) properly.

So, yeah I think your logic is bang on there and I look forward to seeing it implemented.

Keep up the good work! :-)
I'm not sure just how quickly I'll get this done, though I'll put it at the very top of the SrvrPowerCtrl todo list. I'm operating in August mode: brain totally disengaged. And I'm also in the middle of a small remodeling project that has my house so trashed that I can't think straight: can't even find a hammer, let alone think through logical problems in code.