void waitForExit()
{
int socketExceptionCount = 0;
Runtime runtime = Runtime.getRuntime();
ShutdownSystem shutdown = _resinSystem.getService(ShutdownSystem.class);
if (shutdown == null) {
throw new IllegalStateException(L.l("'{0}' requires an active {1}",
this,
ShutdownSystem.class.getSimpleName()));
}
/*
* If the server has a parent process watching over us, close
* gracefully when the parent dies.
*/
while (! _resin.isClosing()) {
try {
Thread.sleep(10);
if (! checkMemory(runtime)) {
shutdown.shutdown(ExitCode.MEMORY, "Resin shutdown from out of memory");
// dumpHeapOnExit();
return;
}
if (! checkFileDescriptor()) {
shutdown.shutdown(ExitCode.MEMORY,
"Resin shutdown from out of file descriptors");
//dumpHeapOnExit();
return;
}
if (_waitIn != null) {
if (_waitIn.read() >= 0) {
socketExceptionCount = 0;
}
else {
shutdown.shutdown(ExitCode.WATCHDOG_EXIT,
"Stopping due to watchdog or user.");
return;
}
}