Run a Wave Federation Server as Linux Daemon
The Wave Federation Server is written in Java, so it is very handy to run the server as linux daemon. The JavaServiceWrapper (JWS) turns java applications into robust services that boot up automatically and restart automatically following crashes. It’s free for open source programs and has very reasonable licensing fees for commercial software.
I used JWS to start the Wave Federation Server instead of starting the server with the original run-server.sh bash script.
Download the JavaServiceWrapper:
%> wget http://wrapper.tanukisoftware.org/download/3.3.5/wrapper-linux-x86-64-3.3.5.tar.gz %> tar xvf wrapper-linux-x86-64-3.3.5.tar.gz
I created a new directory (e.g. bin) in the wave-protocol workspace and copied the relevant wrapper files into this directory. You should have the following files in the ./bin directory:
%> bin/wrapper %> bin/libwrapper.so %> bin/wrapper.jar %> bin/wrapper.conf %> bin/wave.key %> bin/wave.cert %> bin/wrapper.sh
The important files are the configuration “wrapper.conf” and the startup script “wrapper.sh”. I just took the script from the JavaSericeWrapper distribution and renamed it to wrapper.sh. The changes to the default script are to adjust the application name and application long name.
My wrapper.conf:
wrapper.java.command=java wrapper.java.command.loglevel=INFO wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp wrapper.java.classpath.1=./wrapper.jar wrapper.java.classpath.2=../dist/fedone-0.2.jar wrapper.java.library.path.1=. wrapper.java.additional.auto_bits=TRUE wrapper.java.initmemory=128 wrapper.java.maxmemory=256 wrapper.app.parameter.1=org.waveprotocol.wave.examples.fedone.ServerMain wrapper.app.parameter.2=--client_frontend_hostname=wave.foobar.com wrapper.app.parameter.3=--client_frontend_port=9876 wrapper.app.parameter.4=--xmpp_component_name=wave wrapper.app.parameter.5=--xmpp_server_hostname=foobar.com wrapper.app.parameter.6=--xmpp_server_ip=foobar.com wrapper.app.parameter.7=--xmpp_server_port=5275 wrapper.app.parameter.8=--xmpp_server_secret=<secret> wrapper.app.parameter.9=--xmpp_server_ping=acmewave.com wrapper.app.parameter.10=--certificate_private_key=wave.key wrapper.app.parameter.11=--certificate_files=wave.cert wrapper.app.parameter.12=--certificate_domain=foobar.com wrapper.app.parameter.13=--waveserver_disable_verification=true wrapper.console.format=PM wrapper.console.loglevel=INFO wrapper.logfile=../logs/wrapper.log wrapper.logfile.format=LPTM wrapper.logfile.loglevel=INFO wrapper.logfile.maxsize=0 wrapper.logfile.maxfiles=0 wrapper.syslog.loglevel=NONE
Now start the server with:
%> ./wrapper.sh console
This will start the server as a foreground process and you can kill it with CTRL-C. To start the server as daemon just type:
%> ./wrapper.sh start