Follow the sections below to run WSO2 EI as a Linux service:
Prerequisites
- Download the binary distribution of WSO2 EI 6.6.0 and extract the ZIP file. This will be your
<EI_HOME>
. Be sure that the installation prerequisites are fulfilled.
Be sure to set up a compatible JDK and point the java_home variable to your JDK instance.
Running the product as a Linux service
To run the product as a service, create a startup script and add it to the boot sequence. The basic structure of the startup script has three parts (i.e., start, stop and restart) as follows:
#!/bin/bash case “$1″ in start) echo “Starting the Service” ;; stop) echo “Stopping the Service” ;; restart) echo “Restarting the Service” ;; *) echo $”Usage: $0 {start|stop|restart}” exit 1 esac
Given below is a sample startup script.
This sample script is for the ESB profile of WSO2 EI. You can use it for other profiles by changing the directory path of the corresponding script in the value of the
startcmd
,restartcmd
, andstopcmd
properties based on the profile you need to start. You can update thePROFILE_HOME
to<EI_HOME>/wso2/<PROFILE_NAME>.
#! /bin/sh export JAVA_HOME="/usr/lib/jvm/jdk1.7.0_07" startcmd='<PROFILE_HOME>/bin/wso2server.sh start' restartcmd='<PROFILE_HOME>/bin/wso2server.sh restart' stopcmd='<PROFILE_HOME>/bin/wso2server.sh stop' case "$1" in start) echo "Starting the WSO2 Server ..." su -c "${startcmd}" user1 ;; restart) echo "Re-starting the WSO2 Server ..." su -c "${restartcmd}" user1 ;; stop) echo "Stopping the WSO2 Server ..." su -c "${stopcmd}" user1 ;; *) echo "Usage: $0 {start|stop|restart}" exit 1 esac
In the above script, the server is started as a user by the name user1 rather than the root user. For example,
su -c "${startcmd}" user1
#! /bin/sh export JAVA_HOME="/usr/lib/jvm/jdk1.7.0_07" startcmd='<PROFILE_HOME>/bin/wso2server.sh start' restartcmd='<PROFILE_HOME>/bin/wso2server.sh restart' stopcmd='<PROFILE_HOME>/bin/wso2server.sh stop' case "$1" in start) echo "Starting the WSO2 Server ..." su -c "${startcmd}" user1 ;; restart) echo "Re-starting the WSO2 Server ..." su -c "${restartcmd}" user1 ;; stop) echo "Stopping the WSO2 Server ..." su -c "${stopcmd}" user1 ;; *) echo "Usage: $0 {start|stop|restart}" exit 1 esac
Add the script to
/etc/init.d/
directory.If you want to keep the scripts in a location other than
/etc/init.d/
folder , you can add a symbolic link to the script in/etc/init.d/
and keep the actual script in a separate location. Say your script name is prodserver and it is in/opt/WSO2/
folder, then the commands for adding a link to/etc/init.d/
is as follows:Make executable:
sudo chmod a+x /opt/WSO2/prodserver
- Add a link to
/etc/init.d/
:sudo ln -snf /opt/WSO2/prodserver /etc/init.d/prodserver
Install the startup script to respective runlevels using the command
update-rc.d
. For example, give the following command for the sample script shown in step1:sudo update-rc.d prodserver defaults
Thedefaults
option in the above command makes the service to start in runlevels 2,3,4 and 5 and to stop in runlevels 0,1 and 6.A runlevel is a mode of operation in Linux (or any Unix-style operating system). There are several runlevels in a Linux server and each of these runlevels is represented by a single digit integer. Each runlevel designates a different system configuration and allows access to a different combination of processes.
You can now start, stop and restart the server using
service <service name>
{start|stop|restart}
command. You will be prompted for the password of the user (or root) who was used to start the service.