11 May Installing WSO2 carbon based products as a Linux systemd service
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.
# 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
# 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
# wso2server.sh 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.
# Can optionally be set, but the wso2server.sh 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 wso2server.sh start|stop commands
# directly from command line in combination with systemctl. 'Systemctl status' will
# not detect that wso2server.sh 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.