Vert.x 3 init.d Script
Let’s say you have a Vert.x 3 application you want to install on a Linux server. But you want the old school way (I mean not the Docker way ☺). So, in other words, you need an init.d script. This post proposes an init.d script that you can use to start/stop/restart a Vert.x 3 application.
Prerequisites
The proposed script assumes your application is packaged as a fat jar. So, your application is going to be launched using java -jar your-fat-jar ...
.
The script
The init.d scripts have to reply to a set of commands:
start
: starts the application (if not yet started)stop
: stops the application (if started)status
: let you know if the application is started or notrestart
: restart the application
These commands are invoked using:
In general, service scripts are hooked in the boot and shutdown sequences to start and stop automatically during the system starts and stops.
So, enough talks, let’s look at the script:
Using the script
First download the script from the here.
You need to set a couple of variables located at the beginning of the file:
The rest of the script can stay as it is, but feel free to adapt it to your needs. Once you have set these variables based on your environment, move the file to /etc/init.d
and set it as executable:
Then, you should be able to start your application using:
Depending to your operating system, adding the hooks to the boot and shutdown sequence differs. For instance on Ubuntu you need to use the update-rc.d
command while on CentOS chkconfig
is used
That’s all, enjoy !