log.info("Instance will live " + timeToLive + " seconds.");
NSLog.out.appendln("Instance will live " + timeToLive + " seconds.");
// add a fudge factor of around 10 minutes
timeToLive += Math.random() * 600;
NSTimestamp exitDate = (new NSTimestamp()).timestampByAddingGregorianUnits(0, 0, 0, 0, 0, timeToLive);
WOTimer t = new WOTimer(exitDate, 0, this, "killInstance", null, null, false);
t.schedule();
}
int timeToDie = ERXProperties.intForKey("ERTimeToDie");
if (timeToDie > 0) {
log.info("Instance will not live past " + timeToDie + ":00.");
NSLog.out.appendln("Instance will not live past " + timeToDie + ":00.");
NSTimestamp now = new NSTimestamp();
int s = (timeToDie - ERXTimestampUtilities.hourOfDay(now)) * 3600 - ERXTimestampUtilities.minuteOfHour(now) * 60;
if (s < 0)
s += 24 * 3600; // how many seconds to the deadline
// deliberately randomize this so that not all instances restart at
// the same time
// adding up to 1 hour
s += (Math.random() * 3600);
NSTimestamp stopDate = now.timestampByAddingGregorianUnits(0, 0, 0, 0, 0, s);
WOTimer t = new WOTimer(stopDate, 0, this, "startRefusingSessions", null, null, false);
t.schedule();
}
super.run();
}
catch (RuntimeException t) {
if (ERXApplication._wasMainInvoked) {