commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject svn commit: r355064 - /jakarta/commons/proper/daemon/trunk/xdocs/jsvc.xml
Date Thu, 08 Dec 2005 10:21:10 GMT
Author: jfclere
Date: Thu Dec  8 02:21:06 2005
New Revision: 355064

Add a section "How jsvc works".


Modified: jakarta/commons/proper/daemon/trunk/xdocs/jsvc.xml
--- jakarta/commons/proper/daemon/trunk/xdocs/jsvc.xml (original)
+++ jakarta/commons/proper/daemon/trunk/xdocs/jsvc.xml Thu Dec  8 02:21:06 2005
@@ -159,7 +159,7 @@
 You have to write a Class (MyClass) that implements the following methods:
-  <li>void init(String[] arguments): Here open the configuration files, create the
trace file, create
+  <li>void load(String[] arguments): Here open the configuration files, create the
trace file, create
       the ServerSockets, the Threads</li>
   <li>void start(): Start the Thread, accept incomming connections</li>
   <li>void stop(): Inform the Thread to live the run(), close the ServerSockets</li>
@@ -168,6 +168,73 @@
 Store it in a jarfile and use as above:
   ./jsvc -cp commons-daemon.jar:my.jar MyClass
+<section name="How jsvc works">
+Jsvc uses 3 processes: a launcher process, a controller process and a controlled process.
+The controlled process is also the main java thread, if the JVM crashes
+the controller will restart it in the next minute.
+Jsvc is a daemon process so it should be started as root and the -user parameter
+allows to downgrade to an unprivilegded user.
+When -wait parameter is used, the launcher process waits until the controller says
+"I am ready", otherwise it returns after creating the controller process.
+<subsection name="Forks in jakarta-daemon">
+Launcher process:
+  fork()
+  parent: wait_child(), wait until JAVA service started when the child says "I am ready".
+  child: controller process.
+Controller process:
+  while (fork()) {
+    parent: wait_for_child.
+      if exited and restart needed continue
+      else exit.
+    child: exit(child()). controlled process.
+  }
+Controlled process:
+In child(): controlled process.
+  init_JVM().
+  load_service().
+  start_service().
+  say "I am ready"
+  wait for signal or pool for stop
+  stop_service().
+  destroy_service().
+  destroy_JVM().
+  exit (with different codes so that parent knows if it has to restart us).
+Note: The controller process uses signals to stop the controlled process.
+<subsection name="Downgrading user">
+On linux setuid()/setgid() + capabilities are used on other unix setgid/initgroups are used.
+we have something like:
+/* as root */
+load_service. /*  java_load() calls the load method */
+downgrade user (set_caps() or set_user_group())
+/* as the user $USER (from -user $USER parameter) */
+start_service. /* java_start() calls the start method */

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message