Jsvc is working fine on my machine and on other machines, however on a
particular one, it is not working.

In the logs I get "Service killed by signal 11".

I am using a simple daemon for tests (here attached). I compiled it
with javac -cp /usr/share/java/commons-daemon.jar MyDaemon.java. Jsvc
is installed on Ubuntu 16.04 LTS with apt-get and it is version
1.0.15-dev.

When I run it in the logs I only get "Service killed by signal 11". I am using
/usr/bin/jsvc -home /usr/lib/jvm/java-8-oracle/ -cp
/usr/share/java/commons-daemon.jar:$PWD/ -user myuser -pidfile
/tmp/mydaemon.pid -outfile /tmp/test.out.log -errfile '&1'  MyDaemon
-one -two

Starting it with -debug, I get no much more (here attached debug.txt).

I cannot stop it with -stop and I have to kill -9 it.

What should I do?
Do you have any idea?

Thanks!
Switching umask back to 002 from 077
Cannot set supplement group list for user 'myuser'
No need to change user to 'myuser'!
Using default JVM in /usr/lib/jvm/java-8-oracle//jre/lib/amd64/server/libjvm.so
Attemtping to load library 
/usr/lib/jvm/java-8-oracle//jre/lib/amd64/server/libjvm.so
JVM library /usr/lib/jvm/java-8-oracle//jre/lib/amd64/server/libjvm.so loaded
JVM library entry point found (0xC9FA1D20)
+-- DUMPING JAVA VM CREATION ARGUMENTS -----------------
| Version:                       0x010004
| Ignore Unrecognized Arguments: True
| Extra options:                 1
|   "-Djava.class.path=/usr/share/java/commons-daemon.jar:/home/myuser/" 
(0x00000000)
+-------------------------------------------------------
| Internal options:              4
|   "-Dcommons.daemon.process.id=18225" (0x00000000)
|   "-Dcommons.daemon.process.parent=18222" (0x00000000)
|   "-Dcommons.daemon.version=1.0.15-dev" (0x00000000)
|   "abort" (0x00405af0)
+-------------------------------------------------------
Service killed by signal 11
Waiting 60 s to prevent looping

import org.apache.commons.daemon.Daemon;
import org.apache.commons.daemon.DaemonContext;
import org.apache.commons.daemon.DaemonInitException;

public class MyDaemon implements Daemon {

    private Thread myThread; 
    private volatile boolean stopped = false;
    private volatile boolean lastOneWasATick = false;
   
    @Override
    public void init(DaemonContext daemonContext) throws DaemonInitException, Exception {
        /*
         * Construct objects and initialize variables here.
         * You can access the command line arguments that would normally be passed to your main() 
         * method as follows:
         */
        String[] args = daemonContext.getArguments(); 
       
        System.out.println(java.util.Arrays.toString(args));

        myThread = new Thread(){
            private long lastTick = 0;
           
            @Override
            public synchronized void start() {
                MyDaemon.this.stopped = false;
                super.start();
            }

            @Override
            public void run() { 

                try {
                    while(!stopped){
                        long now = System.currentTimeMillis();
                        Thread.sleep(100);
                        if(now - lastTick >= 1000){
                            System.out.println(!lastOneWasATick ? "tick" : "tock");
                            lastOneWasATick = !lastOneWasATick;
                            lastTick = now; 
                        }
                    }
                } catch(InterruptedException e){ }

            }
        };
        System.out.println("initialized");
    }

    @Override
    public void start() throws Exception {
        myThread.start();
        System.out.println("started");
    }

    @Override
    public void stop() throws Exception {
        stopped = true;
        try{
            myThread.join(1000);
        }catch(InterruptedException e){
            System.err.println(e.getMessage());
            throw e;
        }
    
        //System.out.println("waiting to stop");
        //Thread.sleep(5000);
        
        System.out.println("stopped");
    }
   
    @Override
    public void destroy() {
        myThread = null;
        System.out.println("destroyed");
    }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org

Reply via email to