Java Service Management with YAJSW

by actionjack on February 10, 2012 | 2 comments

Ok so what actually is Java Service Management? Well it means easily enabling your java application to be run as a daemon with all the bells and whistles e.g. clean service stopping and starting, logging and jmx profiling.

I was working on a project that ran a java jar file e.g. java -cp application.jar and I initially wrote a simple initscript to stop and start it.Unfortunately it would not daemonize cleanly and dump tons of “useful” info and debug data to the console, eventually it got to the point where I only felt comfortable starting it in using screen.

I finally got time to revisit the situation and look at Tanuki’s Java Service Wrapper software, unfortunately it was incompatible with the project I was working on (and by incompatible I mean it was going to cost me lots and lots of license fees).

Enter YAJSW – Yet Another Java Service Wrapper (http://yajsw.sourceforge.net/):

“YAJSW is a java centric implementation of the java service wrapper by tanuki (JSW).
It aims at being mostly configuration compliant with the original. It should therefore be easy to switch from JSW to YAJSW.”

And it only took me minutes to get working:

    • Download yajsw from Sourceforge
    • unzip to your application’s working directory
    • Run the java application and go to $applicationdir/yajsw/bat
    • Change the mode to all the shell scripts e.g. chmod a+x *.sh
    • Run ./genConfig.sh $java_app_pid
    • Edit $applicationdir/yajsw/conf/wrapper.conf and customise it to your needs
    • Run ./runConsole.sh to check if the application is running correctly.
    • If you want to install the service run ./installDamon.sh this will create the required initscripts and place them into /etc/init.d/ and /etc/rc.d/runlevel directories.
    • You can then choose to either run the startService or stopService shell scripts or use the newly created one in /etc/init.d.

More detailed configuration can be found on their main site and this one is definitely a keeper for my java deployment toolkit.

2 comments

I downloaded version 11 and it does not have installService.sh as you mentioned. Same goes for last beta version 10.12

So where is the installService.sh ?

by Raad on March 29, 2012 at 1:45 pm. Reply #

Hi Raad,

Thanks for pointing out the error it should be ./installDaemon.sh, I’ll correct the entry and the slidedeck.

ActionJack

by actionjack on March 30, 2012 at 9:02 am. Reply #

Leave your comment

Required.

Required. Not published.

If you have one.