Revision: 1252
http://svn.sourceforge.net/wrapper/?rev=1252&view=rev
Author: mortenson
Date: 2006-11-10 15:52:54 -0800 (Fri, 10 Nov 2006)
Log Message:
-----------
Add support for the SIGUSR1 and SIGUSR2 signals so they can now trigger a shutdown, restart or be forwarded to the JVM for custom functionality. Based on a patch by Robey Pointer.
Modified Paths:
--------------
trunk/wrapper/build.xml
trunk/wrapper/doc/revisions.txt
trunk/wrapper/src/c/org_tanukisoftware_wrapper_WrapperManager.h
trunk/wrapper/src/c/wrapper.c
trunk/wrapper/src/c/wrapper.h
trunk/wrapper/src/c/wrapper_unix.c
trunk/wrapper/src/c/wrapperjni_unix.c
trunk/wrapper/src/documentation/english.uris
trunk/wrapper/src/documentation/xdocs/english/properties.xml
trunk/wrapper/src/documentation/xdocs/english/props-unix.xml
trunk/wrapper/src/documentation/xdocs/english/release-notes.xml
trunk/wrapper/src/java/org/tanukisoftware/wrapper/WrapperManager.java
Added Paths:
-----------
trunk/wrapper/src/documentation/xdocs/english/prop-signal-mode-usr1.xml
trunk/wrapper/src/documentation/xdocs/english/prop-signal-mode-usr2.xml
Modified: trunk/wrapper/build.xml
===================================================================
--- trunk/wrapper/build.xml 2006-11-10 23:10:57 UTC (rev 1251)
+++ trunk/wrapper/build.xml 2006-11-10 23:52:54 UTC (rev 1252)
@@ -429,6 +429,7 @@
classpath="${build.classes}">
<class name="org.tanukisoftware.wrapper.WrapperManager"/>
</javah>
+ <fixcrlf srcdir="${src.dir}/c" includes="org_tanukisoftware_wrapper_WrapperManager.h" eol="lf" />
</target>
<target name="msvc-missing" depends="init:msg" if="msvc.missing">
<condition property="msvc.home.v8_c" value="${msvc.home.v8_64_c}">
Modified: trunk/wrapper/doc/revisions.txt
===================================================================
--- trunk/wrapper/doc/revisions.txt 2006-11-10 23:10:57 UTC (rev 1251)
+++ trunk/wrapper/doc/revisions.txt 2006-11-10 23:52:54 UTC (rev 1252)
@@ -29,6 +29,10 @@
* Add the -lm to the command line when building Linux 32 and 64 bit versions
of the wrapper on Linux. This is to support building on recent Debian
and Ubuntu versions. Thanks to Robey Pointer for the patch.
+* Add support for the SIGUSR1 and SIGUSR2 signals so they can now trigger a
+ shutdown, restart or be forwarded to the JVM for custom functionality.
+ See the wrapper.signal.mode.usr1 and wrapper.signal.mode.usr2 properties.
+ Based on a patch by Robey Pointer.
3.2.3
* Add support for x86 Mac OS X distributions.
Modified: trunk/wrapper/src/c/org_tanukisoftware_wrapper_WrapperManager.h
===================================================================
--- trunk/wrapper/src/c/org_tanukisoftware_wrapper_WrapperManager.h 2006-11-10 23:10:57 UTC (rev 1251)
+++ trunk/wrapper/src/c/org_tanukisoftware_wrapper_WrapperManager.h 2006-11-10 23:52:54 UTC (rev 1252)
@@ -61,6 +61,10 @@
#define org_tanukisoftware_wrapper_WrapperManager_WRAPPER_CTRL_TERM_EVENT 204L
#undef org_tanukisoftware_wrapper_WrapperManager_WRAPPER_CTRL_HUP_EVENT
#define org_tanukisoftware_wrapper_WrapperManager_WRAPPER_CTRL_HUP_EVENT 205L
+#undef org_tanukisoftware_wrapper_WrapperManager_WRAPPER_CTRL_USR1_EVENT
+#define org_tanukisoftware_wrapper_WrapperManager_WRAPPER_CTRL_USR1_EVENT 206L
+#undef org_tanukisoftware_wrapper_WrapperManager_WRAPPER_CTRL_USR2_EVENT
+#define org_tanukisoftware_wrapper_WrapperManager_WRAPPER_CTRL_USR2_EVENT 207L
#undef org_tanukisoftware_wrapper_WrapperManager_WRAPPER_LOG_LEVEL_DEBUG
#define org_tanukisoftware_wrapper_WrapperManager_WRAPPER_LOG_LEVEL_DEBUG 1L
#undef org_tanukisoftware_wrapper_WrapperManager_WRAPPER_LOG_LEVEL_INFO
Modified: trunk/wrapper/src/c/wrapper.c
===================================================================
--- trunk/wrapper/src/c/wrapper.c 2006-11-10 23:10:57 UTC (rev 1251)
+++ trunk/wrapper/src/c/wrapper.c 2006-11-10 23:52:54 UTC (rev 1252)
@@ -2532,6 +2532,12 @@
/** Configure the HUP signal handler. */
wrapperData->signalHUPMode = getSignalMode(getStringProperty(properties, "wrapper.signal.mode.hup", NULL), WRAPPER_SIGNAL_MODE_FORWARD);
+
+ /** Configure the USR1 signal handler. */
+ wrapperData->signalUSR1Mode = getSignalMode(getStringProperty(properties, "wrapper.signal.mode.usr1", NULL), WRAPPER_SIGNAL_MODE_FORWARD);
+
+ /** Configure the USR2 signal handler. */
+ wrapperData->signalUSR2Mode = getSignalMode(getStringProperty(properties, "wrapper.signal.mode.usr2", NULL), WRAPPER_SIGNAL_MODE_FORWARD);
}
}
#endif
Modified: trunk/wrapper/src/c/wrapper.h
===================================================================
--- trunk/wrapper/src/c/wrapper.h 2006-11-10 23:10:57 UTC (rev 1251)
+++ trunk/wrapper/src/c/wrapper.h 2006-11-10 23:52:54 UTC (rev 1252)
@@ -265,6 +265,8 @@
#else /* UNIX */
int daemonize; /* TRUE if the process should be spawned as a daemon process on launch. */
int signalHUPMode; /* Controls what happens when the Wrapper receives a HUP signal. */
+ int signalUSR1Mode; /* Controls what happens when the Wrapper receives a USR1 signal. */
+ int signalUSR2Mode; /* Controls what happens when the Wrapper receives a USR2 signal. */
#endif
};
Modified: trunk/wrapper/src/c/wrapper_unix.c
===================================================================
--- trunk/wrapper/src/c/wrapper_unix.c 2006-11-10 23:10:57 UTC (rev 1251)
+++ trunk/wrapper/src/c/wrapper_unix.c 2006-11-10 23:52:54 UTC (rev 1252)
@@ -202,6 +202,10 @@
return "SIGTERM";
case SIGHUP:
return "SIGHUP";
+ case SIGUSR1:
+ return "SIGUSR1";
+ case SIGUSR2:
+ return "SIGUSR2";
default:
return "UNKNOWN";
}
@@ -465,6 +469,30 @@
}
/**
+ * Handle USR1 signals.
+ */
+void sigActionUSR1(int sigNum, siginfo_t *sigInfo, void *na) {
+ /* On UNIX the calling thread is the actual thread being interrupted
+ * so it has already been registered with logRegisterThread. */
+
+ descSignal(sigInfo);
+
+ sigActionCommon(sigNum, "USR1", sigInfo, wrapperData->signalUSR1Mode);
+}
+
+/**
+ * Handle USR2 signals.
+ */
+void sigActionUSR2(int sigNum, siginfo_t *sigInfo, void *na) {
+ /* On UNIX the calling thread is the actual thread being interrupted
+ * so it has already been registered with logRegisterThread. */
+
+ descSignal(sigInfo);
+
+ sigActionCommon(sigNum, "USR2", sigInfo, wrapperData->signalUSR2Mode);
+}
+
+/**
* Registers a single signal handler.
*/
int registerSigAction(int sigNum, void (*sigAction)(int, siginfo_t *, void *)) {
@@ -509,6 +537,8 @@
sigaddset(&signal_mask, SIGQUIT);
sigaddset(&signal_mask, SIGALRM);
sigaddset(&signal_mask, SIGHUP);
+ sigaddset(&signal_mask, SIGUSR1);
+ sigaddset(&signal_mask, SIGUSR2);
rc = pthread_sigmask(SIG_BLOCK, &signal_mask, NULL);
if (rc != 0) {
log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_ERROR, "Could not mask signals for timer thread.");
@@ -595,7 +625,9 @@
registerSigAction(SIGQUIT, sigActionQuit) ||
registerSigAction(SIGCHLD, sigActionChildDeath) ||
registerSigAction(SIGTERM, sigActionTermination) ||
- registerSigAction(SIGHUP, sigActionHangup)) {
+ registerSigAction(SIGHUP, sigActionHangup) ||
+ registerSigAction(SIGUSR1, sigActionUSR1) ||
+ registerSigAction(SIGUSR2, sigActionUSR2)) {
retval = -1;
}
Modified: trunk/wrapper/src/c/wrapperjni_unix.c
===================================================================
--- trunk/wrapper/src/c/wrapperjni_unix.c 2006-11-10 23:10:57 UTC (rev 1251)
+++ trunk/wrapper/src/c/wrapperjni_unix.c 2006-11-10 23:52:54 UTC (rev 1252)
@@ -80,6 +80,22 @@
wrapperJNIHandleSignal(org_tanukisoftware_wrapper_WrapperManager_WRAPPER_CTRL_HUP_EVENT);
}
+/**
+ * Handle usr1 signals.
+ */
+void handleUsr1(int sig_num) {
+ signal(SIGUSR1, handleUsr1);
+ wrapperJNIHandleSignal(org_tanukisoftware_wrapper_WrapperManager_WRAPPER_CTRL_USR1_EVENT);
+}
+
+/**
+ * Handle usr2 signals.
+ */
+void handleUsr2(int sig_num) {
+ signal(SIGUSR2, handleUsr1);
+ wrapperJNIHandleSignal(org_tanukisoftware_wrapper_WrapperManager_WRAPPER_CTRL_USR2_EVENT);
+}
+
/*
* Class: org_tanukisoftware_wrapper_WrapperManager
* Method: nativeInit
@@ -99,6 +115,8 @@
signal(SIGINT, handleInterrupt);
signal(SIGTERM, handleTermination);
signal(SIGHUP, handleHangup);
+ signal(SIGUSR1, handleUsr1);
+ signal(SIGUSR2, handleUsr2);
/* Store the current process Id */
wrapperProcessId = getpid();
Modified: trunk/wrapper/src/documentation/english.uris
===================================================================
--- trunk/wrapper/src/documentation/english.uris 2006-11-10 23:10:57 UTC (rev 1251)
+++ trunk/wrapper/src/documentation/english.uris 2006-11-10 23:52:54 UTC (rev 1252)
@@ -106,6 +106,8 @@
english/prop-restart-reload-configuration.html
english/prop-shutdown-timeout.html
english/prop-signal-mode-hup.html
+english/prop-signal-mode-usr1.html
+english/prop-signal-mode-usr2.html
english/prop-single-invocation.html
english/prop-startup-delay.html
english/prop-startup-timeout.html
Added: trunk/wrapper/src/documentation/xdocs/english/prop-signal-mode-usr1.xml
===================================================================
--- trunk/wrapper/src/documentation/xdocs/english/prop-signal-mode-usr1.xml (rev 0)
+++ trunk/wrapper/src/documentation/xdocs/english/prop-signal-mode-usr1.xml 2006-11-10 23:52:54 UTC (rev 1252)
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "../dtd/docbook/4.1.2/docbookx.dtd">
+
+<!-- ********************************************************************
+ $Id: prop-signal-mode-usr1.xml 1182 2006-09-14 04:02:37Z mortenson $
+ ******************************************************************** -->
+
+<chapter id="prop-signal-mode-usr1">
+ <title>wrapper.signal.mode.usr1 Property</title>
+ <section>
+ <title>Configuration Property Overview</title>
+ <itemizedlist>
+ <listitem>
+ <ulink url="properties.html">Configuration Property Overview</ulink>
+ </listitem>
+ <listitem>
+ <ulink url="props-unix.html">Linux/Unix Configuration Properties</ulink>
+ </listitem>
+ <listitem>
+ <ulink url="properties.html#name">Property List by Name</ulink>
+ </listitem>
+ </itemizedlist>
+ </section>
+ <section>
+ <title>wrapper.signal.mode.usr1</title>
+ <para>
+ Makes it possible to control what the Wrapper process does when a
+ USR1 signal is received. Valid modes include:
+ <literal moreinfo="none">IGNORE</literal> to do nothing,
+ <literal moreinfo="none">RESTART</literal> to restart the JVM,
+ <literal moreinfo="none">SHUTDOWN</literal> to shutdown, or
+ <literal moreinfo="none">FORWARD</literal> to forward the signal
+ to the JVM process. The default value is
+ <literal moreinfo="none">FORWARD</literal>.
+ </para>
+ <para>
+ If the <ulink url="prop-ignore-signals.html">wrapper.ignore_signals</ulink>
+ property is set, this property will function as if it has the value of
+ <literal moreinfo="none">IGNORE</literal>.
+ </para>
+ <para>
+ If the signal is forwarded to the JVM, user code will have the
+ opportunity to handle the signal by either processing the appropriate
+ WrapperControlEvent event or via a custom WrapperListener implementation.
+ See the javadocs for those classes for further details.
+ </para>
+ <informalexample>
+ <simpara><emphasis>Example:</emphasis></simpara>
+ <screen format="linespecific"><![CDATA[wrapper.signal.mode.usr1=FORWARD]]></screen>
+ </informalexample>
+ <note>
+ <para>
+ <ulink url="prop-restart-reload-configuration.html">Reloading</ulink>
+ the Wrapper configuration will have no effect on the value of this property.
+ Changes will not take effect until the Wrapper has been restarted.
+ </para>
+ </note>
+ </section>
+</chapter>
Added: trunk/wrapper/src/documentation/xdocs/english/prop-signal-mode-usr2.xml
===================================================================
--- trunk/wrapper/src/documentation/xdocs/english/prop-signal-mode-usr2.xml (rev 0)
+++ trunk/wrapper/src/documentation/xdocs/english/prop-signal-mode-usr2.xml 2006-11-10 23:52:54 UTC (rev 1252)
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "../dtd/docbook/4.1.2/docbookx.dtd">
+
+<!-- ********************************************************************
+ $Id: prop-signal-mode-usr2.xml 1182 2006-09-14 04:02:37Z mortenson $
+ ******************************************************************** -->
+
+<chapter id="prop-signal-mode-usr2">
+ <title>wrapper.signal.mode.usr2 Property</title>
+ <section>
+ <title>Configuration Property Overview</title>
+ <itemizedlist>
+ <listitem>
+ <ulink url="properties.html">Configuration Property Overview</ulink>
+ </listitem>
+ <listitem>
+ <ulink url="props-unix.html">Linux/Unix Configuration Properties</ulink>
+ </listitem>
+ <listitem>
+ <ulink url="properties.html#name">Property List by Name</ulink>
+ </listitem>
+ </itemizedlist>
+ </section>
+ <section>
+ <title>wrapper.signal.mode.usr2</title>
+ <para>
+ Makes it possible to control what the Wrapper process does when a
+ USR2 signal is received. Valid modes include:
+ <literal moreinfo="none">IGNORE</literal> to do nothing,
+ <literal moreinfo="none">RESTART</literal> to restart the JVM,
+ <literal moreinfo="none">SHUTDOWN</literal> to shutdown, or
+ <literal moreinfo="none">FORWARD</literal> to forward the signal
+ to the JVM process. The default value is
+ <literal moreinfo="none">FORWARD</literal>.
+ </para>
+ <para>
+ If the <ulink url="prop-ignore-signals.html">wrapper.ignore_signals</ulink>
+ property is set, this property will function as if it has the value of
+ <literal moreinfo="none">IGNORE</literal>.
+ </para>
+ <para>
+ If the signal is forwarded to the JVM, user code will have the
+ opportunity to handle the signal by either processing the appropriate
+ WrapperControlEvent event or via a custom WrapperListener implementation.
+ See the javadocs for those classes for further details.
+ </para>
+ <informalexample>
+ <simpara><emphasis>Example:</emphasis></simpara>
+ <screen format="linespecific"><![CDATA[wrapper.signal.mode.usr2=FORWARD]]></screen>
+ </informalexample>
+ <note>
+ <para>
+ <ulink url="prop-restart-reload-configuration.html">Reloading</ulink>
+ the Wrapper configuration will have no effect on the value of this property.
+ Changes will not take effect until the Wrapper has been restarted.
+ </para>
+ </note>
+ </section>
+</chapter>
Modified: trunk/wrapper/src/documentation/xdocs/english/properties.xml
===================================================================
--- trunk/wrapper/src/documentation/xdocs/english/properties.xml 2006-11-10 23:10:57 UTC (rev 1251)
+++ trunk/wrapper/src/documentation/xdocs/english/properties.xml 2006-11-10 23:52:54 UTC (rev 1252)
@@ -321,6 +321,12 @@
<listproperty version="3.2.2">
<ulink url="prop-signal-mode-hup.html">wrapper.signal.mode.hup</ulink>
</listproperty>
+ <listproperty version="3.2.4">
+ <ulink url="prop-signal-mode-usr1.html">wrapper.signal.mode.usr1</ulink>
+ </listproperty>
+ <listproperty version="3.2.4">
+ <ulink url="prop-signal-mode-usr2.html">wrapper.signal.mode.usr2</ulink>
+ </listproperty>
<listproperty version="3.1.2">
<ulink url="prop-single-invocation.html">wrapper.single_invocation</ulink>
</listproperty>
Modified: trunk/wrapper/src/documentation/xdocs/english/props-unix.xml
===================================================================
--- trunk/wrapper/src/documentation/xdocs/english/props-unix.xml 2006-11-10 23:10:57 UTC (rev 1251)
+++ trunk/wrapper/src/documentation/xdocs/english/props-unix.xml 2006-11-10 23:52:54 UTC (rev 1252)
@@ -34,6 +34,12 @@
<listproperty version="3.2.2">
<ulink url="prop-signal-mode-hup.html">wrapper.signal.mode.hup</ulink>
</listproperty>
+ <listproperty version="3.2.4">
+ <ulink url="prop-signal-mode-usr1.html">wrapper.signal.mode.usr1</ulink>
+ </listproperty>
+ <listproperty version="3.2.4">
+ <ulink url="prop-signal-mode-usr2.html">wrapper.signal.mode.usr2</ulink>
+ </listproperty>
</itemizedlist>
</section>
</chapter>
Modified: trunk/wrapper/src/documentation/xdocs/english/release-notes.xml
===================================================================
--- trunk/wrapper/src/documentation/xdocs/english/release-notes.xml 2006-11-10 23:10:57 UTC (rev 1251)
+++ trunk/wrapper/src/documentation/xdocs/english/release-notes.xml 2006-11-10 23:52:54 UTC (rev 1252)
@@ -73,6 +73,15 @@
and Ubuntu versions. Thanks to Robey Pointer for the patch.
</para>
</listitem>
+ <listitem>
+ <para>
+ Add support for the SIGUSR1 and SIGUSR2 signals so they can now trigger a
+ shutdown, restart or be forwarded to the JVM for custom functionality.
+ See the <ulink url="prop-signal-mode-usr1.html">wrapper.signal.mode.usr1</ulink>
+ and <ulink url="prop-signal-mode-usr2.html">wrapper.signal.mode.usr2</ulink>
+ properties. Based on a patch by Robey Pointer.
+ </para>
+ </listitem>
</itemizedlist>
</section>
<section id="3.2.3">
Modified: trunk/wrapper/src/java/org/tanukisoftware/wrapper/WrapperManager.java
===================================================================
--- trunk/wrapper/src/java/org/tanukisoftware/wrapper/WrapperManager.java 2006-11-10 23:10:57 UTC (rev 1251)
+++ trunk/wrapper/src/java/org/tanukisoftware/wrapper/WrapperManager.java 2006-11-10 23:52:54 UTC (rev 1252)
@@ -151,6 +151,12 @@
/** Received when a SIG HUP is received on a UNIX system. */
public static final int WRAPPER_CTRL_HUP_EVENT = 205;
+ /** Received when a SIG USR1 is received on a UNIX system. */
+ public static final int WRAPPER_CTRL_USR1_EVENT = 206;
+
+ /** Received when a SIG USR2 is received on a UNIX system. */
+ public static final int WRAPPER_CTRL_USR2_EVENT = 207;
+
/** Log message at debug log level. */
public static final int WRAPPER_LOG_LEVEL_DEBUG = 1;
/** Log message at info log level. */
@@ -3273,6 +3279,14 @@
eventName = "WRAPPER_CTRL_HUP_EVENT";
ignore = m_ignoreSignals;
break;
+ case WRAPPER_CTRL_USR1_EVENT:
+ eventName = "WRAPPER_CTRL_USR1_EVENT";
+ ignore = m_ignoreSignals;
+ break;
+ case WRAPPER_CTRL_USR2_EVENT:
+ eventName = "WRAPPER_CTRL_USR2_EVENT";
+ ignore = m_ignoreSignals;
+ break;
default:
eventName = "Unexpected event: " + event;
ignore = false;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|