You can stop an application manually using the Monitor application (described in the online document Serving WebObjects). Or you can include code in the application to have it automatically terminate itself under certain conditions. Either way, you might want to turn on application auto-recovery in the Monitor application; that way, when the application dies, it automatically restarts.
public Application() { super(); this.setTimeOut(2*60*60); //shut down if idle 2 hours ... }
public Application() { super(); this.terminateAfterTimeInterval(24*60*60); ... }
After the specified time limit has elapsed, terminateAfterTimeInterval: immediately stops all current processing. If any sessions are active, users may lose information.
// WebScript Application.wos id startDate; - init { [super init]; [self setMinimumActiveSessionCount:1]; return self; } - sleep { if (!startDate) // get the start date from statisticsStore { [[[self statisticsStore] statistics] objectForKey:@"StartedAt"]; } // Compare start date to current date. If the difference is // greater than 24 hours, refuse any new sessions. if (([[NSDate date] timeIntervalSinceReferenceDate] - [startDate timeIntervalSinceReferenceDate]) > 86400) { [self refuseNewSessions:YES]; } }
When the application's active session count falls below the minimum of one session, it will terminate. Sending refuseNewSessions: guarantees that the active session count will eventually fall below the minimum.
Table of Contents Next Section