Turns out USR1 is reserved by the JVM on pretty much every platform but Mac, so only expose USR2 for

injected handling by subclasses.

I had a nice version of this that allowed user controlled handling for any signal to be injected.
Unfortunately it used multibindings from guice, and I'm loathe to add a dependency to narya just for
that.



git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5980 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Charlie Groves
2009-10-21 20:47:55 +00:00
parent 9284f1b4b6
commit 90c97a54b3
4 changed files with 4 additions and 35 deletions
@@ -22,8 +22,6 @@
package com.threerings.presents.server;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import static com.threerings.presents.Log.log;
/**
@@ -73,14 +71,6 @@ public abstract class AbstractSignalHandler
log.info(_repmgr.generateReport(ReportManager.DEFAULT_TYPE));
}
protected void usr1Received ()
{
if (_usr1receiver != null) {
_usr1receiver.received();
}
}
protected void usr2Received ()
{
if (_usr2receiver != null) {
@@ -88,8 +78,7 @@ public abstract class AbstractSignalHandler
}
}
@Inject(optional=true) @Named(SignalReceiver.USR1) protected SignalReceiver _usr1receiver;
@Inject(optional=true) @Named(SignalReceiver.USR2) protected SignalReceiver _usr2receiver;
@Inject(optional=true) protected SignalReceiver _usr2receiver;
@Inject protected PresentsServer _server;
@Inject protected ReportManager _repmgr;
}
@@ -44,9 +44,6 @@ public class NativeSignalHandler extends AbstractSignalHandler
case SignalManager.SIGHUP:
hupReceived();
break;
case SignalManager.SIGUSR1:
usr1Received();
break;
case SignalManager.SIGUSR2:
usr2Received();
break;
@@ -66,6 +63,7 @@ public class NativeSignalHandler extends AbstractSignalHandler
SignalManager.registerSignalHandler(SignalManager.SIGTERM, this);
SignalManager.registerSignalHandler(SignalManager.SIGINT, this);
SignalManager.registerSignalHandler(SignalManager.SIGHUP, this);
SignalManager.registerSignalHandler(SignalManager.SIGUSR2, this);
return true;
}
}
@@ -1,23 +1,10 @@
package com.threerings.presents.server;
/**
* Listens for Unix signals captured by {@link AbstractSignalHandler}.
* If injected into a presents server, listens for a USR2 Unix signal captured by
* {@link AbstractSignalHandler}.
*/
public interface SignalReceiver
{
/**
* Used to mark the receiver for the USR1 signal in guice injection. Bind implementations that
* should receive this signal with
* <code>annotatedWith(Names.named(SignalReceiver.USR1))</code>.
*/
public static final String USR1 = "usr1";
/**
* Used to mark the receiver for the USR2 signal in guice injection. Bind implementations that
* should receive this signal with
* <code>annotatedWith(Names.named(SignalReceiver.USR2))</code>.
*/
public static final String USR2 = "usr2";
void received();
}
@@ -42,11 +42,6 @@ public class SunSignalHandler extends AbstractSignalHandler
intReceived();
}
});
SignalUtil.register(SignalUtil.Number.USR1, new SignalUtil.Handler() {
public void signalReceived (SignalUtil.Number sig) {
usr1Received();
}
});
SignalUtil.register(SignalUtil.Number.USR2, new SignalUtil.Handler() {
public void signalReceived (SignalUtil.Number sig) {
usr2Received();