Tweaks to the way the reboot manager computes scheduled reboots.

- Previously if you scheduled a reboot for 5am every day, but the
server came up at 3am, it would schedule the reboot for 5am the next
day. Subtract a day if the current time is before the rebootHour.
- When skipping weekends always push the time out rather than
pulling it in. Questionable, but so was the previous behavior.
If you set it to reboot daily but skip weekends, it would not
skip weekends.
This commit is contained in:
Ray J. Greenwell
2013-08-23 13:28:02 -07:00
parent c54b158abd
commit e67b9e224f
@@ -28,7 +28,6 @@ import com.samskivert.util.HashIntMap;
import com.samskivert.util.Interval;
import com.samskivert.util.ObserverList;
import com.samskivert.util.StringUtil;
import com.samskivert.util.Calendars.Builder;
import com.threerings.util.MessageBundle;
@@ -80,26 +79,24 @@ public abstract class RebootManager
{
// maybe schedule an automatic reboot based on our configuration
int freq = getDayFrequency();
if (freq == -1) {
int hour = getRebootHour();
if (freq <= 0) {
return false;
}
Builder cal = Calendars.now().zeroTime().addHours(getRebootHour()).addDays(freq);
Calendars.Builder cal = Calendars.now();
int curHour = cal.get(Calendar.HOUR_OF_DAY);
cal = cal.zeroTime().addHours(hour).addDays((curHour < hour) ? (freq - 1) : freq);
// maybe avoid weekends
if (getSkipWeekends()) {
int dow = cal.get(Calendar.DAY_OF_WEEK);
switch (dow) {
switch (cal.get(Calendar.DAY_OF_WEEK)) {
case Calendar.SATURDAY:
if (freq > 1) {
cal.addDays(-1);
}
cal.addDays(2);
break;
case Calendar.SUNDAY:
if (freq > 2) {
cal.addDays(-2);
}
cal.addDays(1);
break;
}
}