Versions
- CentOS 6.3
- Oracle JDK 1.6
Configure
Note: Replace <product> with the abbreviated name of the WSO2 product (API Manager = ‘am’, Data Services Server = ‘dss’, etc) and replace <version> with the version number (’1.3.1′, ’4.0.6′, etc)
1. Edit /etc/init.d/wso2<product>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
#!/bin/sh # # chkconfig: 2345 80 80 # # Bash script to run wso2server.sh as a service # # Note: Normal env variables are discarded by service. So must export JAVA_HOME here, see http://serverfault.com/questions/374404/service-command-and-environment-variables export JAVA_HOME=/usr/java/latest WSO2_HOME=/usr/lib/<wso2 product> WSO2_DAEMON=bin/wso2server.sh WSO2_USER=root START_OPTIONS=start STOP_OPTIONS=stop start() { echo "Starting WSO2 <product>..." su --preserve-environment $WSO2_USER -c "cd $WSO2_HOME && $WSO2_DAEMON $START_OPTIONS" return 0 } stop() { echo "Stopping WSO2 <product>..." su --preserve-environment $WSO2_USER -c "cd $WSO2_HOME && $WSO2_DAEMON $STOP_OPTIONS" return 0 } case "$1" in start) start ;; stop) stop ;; restart) stop start ;; *) echo $"Usage: $0 {start|stop|restart}" exit 1 esac exit $? |
Note: the script hard codes JAVA_HOME, but this can be deferred to the /etc/sysconfig/wso2<product> script (which you must create) if desired. Note that the normal /etc/profile.sh is *not* run for services.
TODO: find better way of setting JAVA_HOME, can’t execute /etc/profile or /etc/profile.d/java.sh directly
2. Make it executable
1 |
sudo chmod +x /etc/init.d/wso2<product> |
2. Start service on boot
1 |
sudo chkconfig wso2<product> on |
Verify
1. Start service
1 |
sudo service wso2<product> start |