The WSO2 documentaton contains an example on how to install WSO2 carbon based servers as a Linux System V init service. Modern Linux systems use systemd as their init system instead of the System V style though.

The below systemd unit configuraton file named “wso2esb.service” contains the configuration to manage a WSO2 carbon based ESB server, together with the rationale of the various settings and usage instructions. This unit file can also be used for other carbon based WSO2 products such as Identity Server, Data Services Server, Data Analytics Server,… by simply replacing the name, absolute paths and other ESB references.

This configuration file was tested on Ubuntu 16.04. Small modifications may be required on other Linux distros, but in general it should work on all distros.[/vc_column_text][vc_column_text el_class=”codeblock”]

# For usage with systemd
# On Ubuntu:
# install by running sudo systemctl enable <absolute path>/wso2esb.service
# start by running sudo systemctl start wso2esb.service
# stop by running sudo systemctl stop wso2esb.service
# check status by running systemctl status wso2esb.service

Description=WSO2 ESB
# If network requirement is not specified, the esb can slow down shutdown
# of the system because of timeouts towards the RDBMS running on another
# server or other dependent remote components.

# The Type=simple approach is not safe: if a user starts the server using the 
# script, systemd doens't know about it and another instance will
# be started when 'systemctl start wso2esb' is executed if the server is still running.
# Type=simple
# ExecStart=CARBON_HOME/bin/

# Can optionally be set, but the script determines it automatically
# Cannot be used within this unit file for variable substitution
# CARBON_HOME = /opt/wso2/wso2esb/wso2esb-5.0.0

# Use WSO2 PID file -> this allows to still use start|stop commands
# directly from command line in combination with systemctl. 'Systemctl status' will
# not detect that start has been executed directly, but will correctly
# stop the server when the system is shutdown or 'systemctl stop' is executed. Systemctl
# will also not start another instance of the server when 'systemctl start' is executed.
ExecStart=/opt/wso2/wso2esb/wso2esb-5.0.0/bin/ start
ExecStop=/opt/wso2/wso2esb/wso2esb-5.0.0/bin/ stop