commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eugene Prokopiev <prokop...@stc.donpac.ru>
Subject [Commons Daemon] How to use jsvc?
Date Thu, 01 Jun 2006 05:39:07 GMT
Hi,

I have a class:

import org.apache.commons.daemon.Daemon;
import org.apache.commons.daemon.DaemonContext;
public class MyDaemon implements Daemon {
     public void init(DaemonContext context) throws Exception {
         System.out.println("init : "+context);
     }
     public void start() throws Exception {
         System.out.println("start");
     }
     public void stop() throws Exception {
         System.out.println("stop");
     }
     public void destroy() {
         System.out.println("destroy");
     }
}

I tried to use it:

# ls -l
total 164
-rw-r--r--  1 john john   1093 Jun  1 08:40 MyDaemon.class
-rw-r--r--  1 john john   9150 May 31 15:02 commons-daemon.jar
-rwxr-xr-x  1 john john 145064 May 31 14:57 jsvc
# ./jsvc -cp .:commons-daemon.jar MyDaemon
# ps aux | grep jsvc
root      1731  0.0  0.0  1372  436 pts/2    S    09:01   0:00 grep jsvc
# ./jsvc -pidfile /var/run/mydaemon.pid -outfile mydaemon.log -errfile 
'&1' -cp .:commons-daemon.jar MyDaemon
# ps aux | grep jsvc
root      1747  0.0  0.0  1372  436 pts/2    S    09:02   0:00 grep jsvc
# cat mydaemon.log
01/06/2006 09:02:28 1737 jsvc.exec error: Cannot find daemon loader 
org/apache/commons/daemon/support/DaemonLoader
01/06/2006 09:02:28 1736 jsvc.exec error: Service exit with a return 
value of 1
# unzip -l commons-daemon.jar
Archive:  commons-daemon.jar
   Length     Date   Time    Name
  --------    ----   ----    ----
         0  05-31-06 15:02   META-INF/
       309  05-31-06 15:02   META-INF/MANIFEST.MF
         0  05-31-06 15:01   org/
         0  05-31-06 15:01   org/apache/
         0  05-31-06 15:01   org/apache/commons/
         0  05-31-06 15:01   org/apache/commons/daemon/
         0  05-31-06 15:01   org/apache/commons/daemon/support/
       304  05-31-06 15:01   org/apache/commons/daemon/Daemon.class
       253  05-31-06 15:01   org/apache/commons/daemon/DaemonContext.class
       426  05-31-06 15:01 
org/apache/commons/daemon/DaemonController.class
       166  05-31-06 15:01   org/apache/commons/daemon/DaemonListener.class
      3853  05-31-06 15:01 
org/apache/commons/daemon/DaemonPermission.class
       255  05-31-06 15:01 
org/apache/commons/daemon/support/DaemonLoader$1.class
      1112  05-31-06 15:01 
org/apache/commons/daemon/support/DaemonLoader$Context.class
      2102  05-31-06 15:01 
org/apache/commons/daemon/support/DaemonLoader$Controller.class
      4735  05-31-06 15:01 
org/apache/commons/daemon/support/DaemonLoader.class
  --------                   -------
     13515                   16 files

What's wrong? Can anybody giver me a working jsvc example? SimpleDaemon 
from source doesn't works too :(

-- 
Thanks,
Eugene Prokopiev


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message