Skip to content

Servoy server SysV init script

Here is a quick servoy server init script I wrote and use at work.  It works pretty well on my debian based machines, although it may be a problem if you have other java apps running as it may catch the wrong PID.  I  could clean that up if i needed, but I personally don’t so if you need help let me know in the comments and I can adjust it.


#!/bin/bash
export SERVOY_HOME=/usr/local/servoy3/

# If there is a different user you would like to run this script as,
# change the following line
export SERVOY_USER=servoy

start() {
OLD_PWD=`pwd`
cd $SERVOY_HOME
CMD="./servoy_server3.sh"
sudo -u $SERVOY_USER "$CMD" > /var/log/servoy.log &
cd $OLD_PWD
}

stop() {
OLD_PWD=`pwd`
cd $SERVOY_HOME
PID=$(ps x -u servoy | grep "java -Djava.awt.headless=true -classpath" | head -n 1 | awk '{print $1}')
sudo -u $SERVOY_USER kill $PID
cd $OLD_PWD
}

case "$1" in
start)
start
;;
stop)
stop
;;
*)
echo "Usage $0 {start|stop}"
exit 1
esac

Post a Comment

Your email is never published nor shared. Required fields are marked *