Shut down all nice and happy like when we get a ctrl-c.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2361 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: PresentsServer.java,v 1.32 2003/03/30 21:27:13 mdb Exp $
|
// $Id: PresentsServer.java,v 1.33 2003/03/31 02:10:37 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.server;
|
package com.threerings.presents.server;
|
||||||
|
|
||||||
@@ -10,6 +10,8 @@ import com.samskivert.util.ObserverList;
|
|||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
import com.samskivert.util.SystemInfo;
|
import com.samskivert.util.SystemInfo;
|
||||||
|
|
||||||
|
import com.threerings.util.signal.SignalManager;
|
||||||
|
|
||||||
import com.threerings.presents.Log;
|
import com.threerings.presents.Log;
|
||||||
import com.threerings.presents.client.Client;
|
import com.threerings.presents.client.Client;
|
||||||
import com.threerings.presents.dobj.DObjectManager;
|
import com.threerings.presents.dobj.DObjectManager;
|
||||||
@@ -28,6 +30,7 @@ import com.threerings.presents.util.Invoker;
|
|||||||
* initialized.
|
* initialized.
|
||||||
*/
|
*/
|
||||||
public class PresentsServer
|
public class PresentsServer
|
||||||
|
implements SignalManager.SignalHandler
|
||||||
{
|
{
|
||||||
/** Used to generate "state of the server" reports. See {@link
|
/** Used to generate "state of the server" reports. See {@link
|
||||||
* #registerReporter}. */
|
* #registerReporter}. */
|
||||||
@@ -87,6 +90,9 @@ public class PresentsServer
|
|||||||
", jvm=" + si.jvmToString() +
|
", jvm=" + si.jvmToString() +
|
||||||
", mem=" + si.memoryToString() + "].");
|
", mem=" + si.memoryToString() + "].");
|
||||||
|
|
||||||
|
// register a ctrl-c handler
|
||||||
|
SignalManager.registerSignalHandler(SignalManager.SIGINT, this);
|
||||||
|
|
||||||
// create our distributed object manager
|
// create our distributed object manager
|
||||||
omgr = new PresentsDObjectMgr();
|
omgr = new PresentsDObjectMgr();
|
||||||
|
|
||||||
@@ -142,6 +148,18 @@ public class PresentsServer
|
|||||||
omgr.run();
|
omgr.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// documentation inherited from interface
|
||||||
|
public boolean signalReceived (int signo)
|
||||||
|
{
|
||||||
|
// this is called when we receive a ctrl-c
|
||||||
|
omgr.postUnit(new Runnable() {
|
||||||
|
public void run () {
|
||||||
|
shutdown();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A report is generated by the presents server periodically in which
|
* A report is generated by the presents server periodically in which
|
||||||
* server entities can participate by registering a {@link Reporter}
|
* server entities can participate by registering a {@link Reporter}
|
||||||
|
|||||||
Reference in New Issue
Block a user