commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1814072 - in /commons/proper/daemon/trunk/src: changes/changes.xml native/unix/man/jsvc.1.xml native/unix/native/arguments.c native/unix/native/arguments.h native/unix/native/help.c native/unix/native/jsvc-unix.c site/xdoc/jsvc.xml
Date Thu, 02 Nov 2017 13:10:05 GMT
Author: markt
Date: Thu Nov  2 13:10:04 2017
New Revision: 1814072

URL: http://svn.apache.org/viewvc?rev=1814072&view=rev
Log:
Fix DAEMON-334
Add a restarts options to jsvc to control the number of permitted restarts after a system
crash.
Patch provided by Brett Delle Grazie

Modified:
    commons/proper/daemon/trunk/src/changes/changes.xml
    commons/proper/daemon/trunk/src/native/unix/man/jsvc.1.xml
    commons/proper/daemon/trunk/src/native/unix/native/arguments.c
    commons/proper/daemon/trunk/src/native/unix/native/arguments.h
    commons/proper/daemon/trunk/src/native/unix/native/help.c
    commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c
    commons/proper/daemon/trunk/src/site/xdoc/jsvc.xml

Modified: commons/proper/daemon/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/changes/changes.xml?rev=1814072&r1=1814071&r2=1814072&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/changes/changes.xml (original)
+++ commons/proper/daemon/trunk/src/changes/changes.xml Thu Nov  2 13:10:04 2017
@@ -130,6 +130,10 @@
       <action issue="DAEMON-374" type="fix" dev="markt" due-to="Rashmi Ranjan Mohanty">
         Add support for Java 9 commoand line arguments to jsvc.
       </action>
+      <action issue="DAEMON-334" type="add" dev="markt" due-to="Brett Delle Grazie">
+        Add a restarts options to jsvc to control the number of permitted
+        restarts after a system crash.
+      </action>
     </release>
   </body>
 </document>

Modified: commons/proper/daemon/trunk/src/native/unix/man/jsvc.1.xml
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/man/jsvc.1.xml?rev=1814072&r1=1814071&r2=1814072&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/unix/man/jsvc.1.xml (original)
+++ commons/proper/daemon/trunk/src/native/unix/man/jsvc.1.xml Thu Nov  2 13:10:04 2017
@@ -47,6 +47,7 @@
       <arg choice='opt'>-check</arg>
       <arg choice='opt'>-user <replaceable>user</replaceable></arg>
       <arg choice='opt'>-wait <replaceable>waittime</replaceable></arg>
+      <arg choice='opt'>-restarts <replaceable>max restart count</replaceable></arg>
       <arg choice='opt'>-umask <replaceable>mask</replaceable></arg>
       <arg choice='opt'>-stop</arg>
       <arg choice='opt'>-verbose<replaceable>:class|gc|jni</replaceable></arg>
@@ -146,6 +147,14 @@
           </para>
         </listitem>
       </varlistentry>
+      <varlistentry>
+        <term><option>-restarts</option> max restart count</term>
+        <listitem>
+          <para>maximum automatic restart count
+             -1=infinite (default), 0=none, 1..(INT_MAX-1)=fixed count
+          </para>
+        </listitem>
+      </varlistentry>
       <varlistentry>
         <term><option>-umask</option> mask</term>
         <listitem>

Modified: commons/proper/daemon/trunk/src/native/unix/native/arguments.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/arguments.c?rev=1814072&r1=1814071&r2=1814072&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/unix/native/arguments.c (original)
+++ commons/proper/daemon/trunk/src/native/unix/native/arguments.c Thu Nov  2 13:10:04 2017
@@ -158,6 +158,7 @@ static arg_data *parse(int argc, char *a
     args->chck    = false;        /* Don't do a check-only startup */
     args->stop    = false;        /* Stop a running jsvc */
     args->wait    = 0;            /* Wait until jsvc has started the JVM */
+    args->restarts = -1;          /* Infinite restarts by default */
     args->install = false;        /* Don't install as a service */
     args->remove  = false;        /* Don't remove the installed service */
     args->service = false;        /* Don't run as a service */
@@ -274,6 +275,15 @@ static arg_data *parse(int argc, char *a
                 return NULL;
             }
         }
+        else if (!strcmp(argv[x], "-restarts")) {
+            temp = optional(argc, argv, x++);
+            if (temp)
+                args->restarts = atoi(temp);
+            if (args->restarts < -1) {
+                log_error("Invalid max restarts [-1,0,...)");
+                return NULL;
+            }
+        }
         else if (!strcmp(argv[x], "-umask")) {
             temp = optional(argc, argv, x++);
             if (temp == NULL) {
@@ -488,6 +498,7 @@ arg_data *arguments(int argc, char *argv
         log_debug("| Check Only:      %s", IsEnabledDisabled(args->chck));
         log_debug("| Stop:            %s", IsTrueFalse(args->stop));
         log_debug("| Wait:            %d", args->wait);
+        log_debug("| Restarts:        %d", args->restarts);
         log_debug("| Run as service:  %s", IsYesNo(args->service));
         log_debug("| Install service: %s", IsYesNo(args->install));
         log_debug("| Remove service:  %s", IsYesNo(args->remove));

Modified: commons/proper/daemon/trunk/src/native/unix/native/arguments.h
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/arguments.h?rev=1814072&r1=1814071&r2=1814072&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/unix/native/arguments.h (original)
+++ commons/proper/daemon/trunk/src/native/unix/native/arguments.h Thu Nov  2 13:10:04 2017
@@ -60,6 +60,8 @@ typedef struct {
     bool stop;
     /** number of seconds to until service started */
     int wait;
+    /** max restarts **/
+    int restarts;
     /** Install as a service (win32) */
     bool install;
     /** Remove when installed as a service (win32) */

Modified: commons/proper/daemon/trunk/src/native/unix/native/help.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/help.c?rev=1814072&r1=1814071&r2=1814072&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/unix/native/help.c (original)
+++ commons/proper/daemon/trunk/src/native/unix/native/help.c Thu Nov  2 13:10:04 2017
@@ -95,6 +95,9 @@ void help(home_data *data)
     printf("    -wait <waittime>\n");
     printf("        wait waittime seconds for the service to start\n");
     printf("        waittime should multiple of 10 (min=10)\n");
+    printf("    -restarts <maxrestarts>\n");
+    printf("        maximum automatic restarts (integer)\n");
+    printf("        -1=infinite (default), 0=none, 1..(INT_MAX-1)=fixed restart count\n");
     printf("    -stop\n");
     printf("        stop the service using the file given in the -pidfile option\n");
     printf("    -keepstdin\n");

Modified: commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c?rev=1814072&r1=1814071&r2=1814072&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c (original)
+++ commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c Thu Nov  2 13:10:04 2017
@@ -126,9 +126,9 @@ static void handler(int sig)
         case SIGUSR1:
              log_debug("Caught SIGUSR1: Reopening logs");
              doreopen = true;
-	break;
+        break;
         case SIGUSR2:
-	     log_debug("Caught SIGUSR2: Scheduling a custom signal");
+             log_debug("Caught SIGUSR2: Scheduling a custom signal");
              dosignal = true;
         break;
         default:
@@ -1262,6 +1262,7 @@ static int run_controller(arg_data *args
                           gid_t gid)
 {
     pid_t pid = 0;
+    int restarts = 0;
     struct sigaction act;
 
     controller_pid = getpid();
@@ -1315,7 +1316,16 @@ static int run_controller(arg_data *args
             /* See java_abort123 (we use this return code to restart when the JVM aborts)
*/
             if (!stopping) {
                 if (status == 123) {
+                    if (args->restarts == 0) {
+                        log_debug("Service failure, restarts disabled");
+                        return 1;
+                    }
+                    if (args->restarts != -1 && args->restarts <= restarts)
{
+                        log_debug("Service failure, restart limit reached, aborting");
+                        return 1;
+                    }
                     log_debug("Reloading service");
+                    restarts++;
                     /* prevent looping */
                     if (laststart + 60 > time(NULL)) {
                         log_debug("Waiting 60 s to prevent looping");
@@ -1343,6 +1353,8 @@ static int run_controller(arg_data *args
                         log_debug("Waiting 60 s to prevent looping");
                         sleep(60);
                     }
+                    /* Normal or user controlled termination, reset restart counter */
+                    restarts = 0;
                     continue;
                 }
             }

Modified: commons/proper/daemon/trunk/src/site/xdoc/jsvc.xml
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/site/xdoc/jsvc.xml?rev=1814072&r1=1814071&r2=1814072&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/site/xdoc/jsvc.xml (original)
+++ commons/proper/daemon/trunk/src/site/xdoc/jsvc.xml Thu Nov  2 13:10:04 2017
@@ -181,11 +181,31 @@ Where options include:
     -wait &lt;waittime&gt;
         wait waittime seconds for the service to start
         waittime should multiple of 10 (min=10)
+    -restarts &lt;maxrestarts&gt;
+        maximum automatic restarts (integer)
+        -1=infinite (default), 0=none, 1..(INT_MAX-1)=fixed restart count
     -stop
         stop the service using the file given in the -pidfile option
     -keepstdin
         does not redirect stdin to /dev/null
-
+    --add-modules=&lt;module name&gt;
+        Java 9 --add-modules option. Passed as it is to JVM
+    --module-path=&lt;module path&gt;
+        Java 9 --module-path option. Passed as it is to JVM
+    --upgrade-module-path=&lt;module path&gt;
+        Java 9 --upgrade-module-path option. Passed as it is to JVM
+    --add-reads=&lt;module name&gt;
+        Java 9 --add-reads option. Passed as it is to JVM
+    --add-exports=&lt;module name&gt;
+        Java 9 --add-exports option. Passed as it is to JVM
+    --add-opens=&lt;module name&gt;
+        Java 9 --add-opens option. Passed as it is to JVM
+    --limit-modules=&lt;module name&gt;
+        Java 9 --limit-modules option. Passed as it is to JVM
+    --patch-module=&lt;module name&gt;
+        Java 9 --patch-module option. Passed as it is to JVM
+    --illegal-access=&lt;value&gt;
+        Java 9 --illegal-access option. Passed as it is to JVM. Refer java help for possible
values.
 </source>
 </p>
 <subsection name="Mac OS X universal binaries">



Mime
View raw message