Category Archives: apache-commons-daemon

Procrun with org.apache.commons.daemon.Daemon

I wrote a Daemon by using the apache commons sample code:

public class LockDaemon implements Daemon {

@Override
public void init(DaemonContext context) throws DaemonInitException, Exception {
    LogManager.getLogger().info("initialized with arguments {}", context.getArguments());
}

@Override
public void start() throws Exception {
    LogManager.getLogger().info("Start called");

}

@Override
public void stop() throws Exception {
    LogManager.getLogger().info("Stop called");
}

@Override
public void destroy() {

}

}

Unfortunately the example does not mention how to install this class with procrun. Procrun needs a static "Start Method", which I do not have when using the code above.

So which start (and stop) method needs to be set for procrun to make the code above work?

conflict error from g++ compiled files while executing ‘make’ command using apache commons daemon via cygwin

I am just a novice in using cygwin ,apache commons daemon ,jsvc.

Involved in a process of writing a daemon using apache commons daemon and execute via cygwin as a linux daemon. so tried the below instruction given, http://commons.apache.org/proper/commons-daemon/jsvc.html

Succeeded in ,

sh support/buildconf.sh

./configure

but, while doing make I am getting conflict errors in g++ compiled files which is in (/usr/include/sys/unistd.h) attached the error below.

         $ make
   (cd native; make  all)
   make[1]: Entering directory '/commons-daemon-1.0.15-native-src/unix/native' 
   gcc -g -O2 -DOS_CYGWIN -DDSO_DLFCN -DNO_SETSID -DCPU=\"amd64\" -Wall -Wstrict-pr 
   ototypes   -ID:\Users\c400618\Documents\softwares\jdk1.6.0_35/include -ID:\Users
   \c400618\Documents\softwares\jdk1.6.0_35/include -c jsvc-unix.c -o jsvc-unix.o
   jsvc-unix.c:74:12: error: static declaration of ‘lockf’ follows non-static declaration                                                                                                                                                                                                                                                                                                                   

   static int lockf(int fildes, int function, off_t size)
        ^
     In file included from /usr/include/stdio.h:29:0,
             from jsvc.h:21,
             from jsvc-unix.c:18:
    /usr/include/sys/unistd.h:136:9: note: previous declaration of ‘lockf’ was here
    int     _EXFUN(lockf, (int __fd, int __cmd, off_t __len));
          ^
    ../Makedefs:32: recipe for target 'jsvc-unix.o' failed
   make[1]: *** [jsvc-unix.o] Error 1
  make[1]: Leaving directory '/commons-daemon-1.0.15-native-src/unix/native'
  Makefile:26: recipe for target 'native/all' failed
  make: *** [native/all] Error 2

used http://mirrors.kernel.com, as a mirror to get g++ gcc compiler , autoconf , GNU make

Got stuck here and not able to generate jsvc executable(looks like a conflict 'lockf'), but no idea whether to correct the header files.

Please help me in resolving the error. Let me know if you need further information regarding the error.

Play framework app as a Windows Service with Apache Commons Daemon

I've been following this link: http://grokbase.com/t/gg/play-framework/132fb45n63/2-1-installing-play-application-as-windows-services to get my play framework app installed as a windows service using Apache Commons Daemon (prunsrv.exe).

The service gets installed but I run into this error in the logs when I try to start it,

    [2014-09-26 21:19:07] [error] [ 4412] Method 'static void start(String[])' not found in Class play/core/server/NettyServer
    [2014-09-26 21:19:07] [error] [ 3016] Failed to start Java
    [2014-09-26 21:19:07] [error] [ 3016] ServiceStart returned 4

Does anyone know how to resolve this ?