Java – How to install WildFly 8.0.0.Final as service on Ubuntu Linux

javaubuntu-12.04wildfly8

I am trying to install the WildFly 8.0.0.Final application server on a Virtual Machine running Ubuntu 12.04 LTS. I've done some searches on Google, but I found only third-party scripts and, I think, non standard ways to do this.

Currently, to start the server, I open an SSH connection to the virtual machine and run the following commands:

cd <WILDFLY_HOME>/bin
nohup standalone.sh -b=0.0.0.0 -bmanagement=0.0.0.0 > /dev/null &

And to stop:

kill <pid of java process running wildfly>

But, what is the best way to install the server as a service on Ubuntu? If I restart the machine, the server will start automatically?

My environment:

  • Ubuntu 12.04 LTS;
  • Java 7;
  • WildFly 8.0.0 Final;

Best Answer

WildFly includes an init.d script in the bin folder...

Follow this steps:

sudo cp $WILDFLY_HOME/bin/init.d/wildfly-init-debian.sh /etc/init.d/wildfly
sudo cp $WILDFLY_HOME/bin/init.d/wildfly.conf /etc/default/wildfly
sudo adduser --system --group --disabled-login wildfly
sudo chown -R wildfly:wildfly $WILDFLY_HOME
sudo update-rc.d wildfly defaults

Modify /etc/default/wildfly to fit your needs... Test.