Creating a Linux systemd service to start the basic runtime


After installing a Linux basic runtime/runtime cluster, it is recommended to configure the system, to start that service automatically at boot time.

Previous Unix/Linux distributions used init.d/sysv type installations. Ubuntu 14 uses Upstart. RedHat 7, CentOS 7, and now Ubuntu 15 use a service manager called systemd.

As a best practice, the basic runtime should be installed as a service user, and not as root. During the basic runtime installation, it is also recommended to decline the option to "Create Symlinks." After the install, follow these steps to set up the service.

First, create the following file, owned by root, substituting the basic serviceName, serviceUserName, pathToInstall, and installDirMountPoint appropriately:

( note: RequresMountsFor, is only needed for runtime cluster or Cloud installs, and can be omitted for basic runtime installations. For installDirMountPoint, use the absolute path to the mount point for your NFS drive )

 

File Name: /etc/systemd/system/[serviceName].service

Example File Name: /etc/systemd/system/atom.service

 

Contents:

[Unit]
Description= Boomi Runtime
After=network.target
RequiresMountsFor=[installDirMountPoint]
[Service]
Type=forking
User=[serviceUserName]
Restart=always
ExecStart=[pathToInstall]/bin/atom start
ExecStop=[pathToInstall]/bin/atom stop
ExecReload=[pathToInstall]/bin/atom restart
[Install]
WantedBy=multi-user.target

 

Next, from the command window, execute the following command:

sudo systemctl enable [serviceName]

 

The Boomi runtime can then be stopped, started, etc, with the following commands:

sudo systemctl start [serviceName]

sudo systemctl restart [serviceName]

sudo systemctl stop [serviceName]

sudo systemctl status -l [serviceName]

 

Run the following command, and verify that the runtime service is running as the correct user:

ps -ef | grep java

 

Reboot the machine, and verify that the service comes back online as expected.

NOTE:- 
The Restart=always configuration means that systemd will automatically restart the service as soon as it is no longer up (unless it is stopped with the systemctl stop command) This means that when restarting via the UI, the restart isn't entirely being done by the restart.sh script, but it is being stopped by the basic runtime restart script and being brought online by systemd. Running the scripts directly can cause the basic runtime to get into a wedged state, so one should avoid directly running the restart.sh script, basic runtime start, and basic runtime stop and instead use systemctl commands and the UI.

 

Reference Links: