Author: Paolo Lulli <paolo@lulli.net>
Add Start/stop script
script/service.sh | 34 ++++++++++++++++++++++++++++++++++
diff --git a/script/service.sh b/script/service.sh new file mode 100755 index 0000000000000000000000000000000000000000..6736fbb4f39405870a87c8c54a8097f5085bd11a --- /dev/null +++ b/script/service.sh @@ -0,0 +1,34 @@ +#! /bin/bash +# +# Yats - yats +# +# This file is licensed under the Affero General Public License version 3 or +# later. See the COPYING file. +# +# Author: Paolo Lulli <kevwe.com> +# Copyright: Paolo Lulli 2024 +# + + +cd $(dirname $0) + +EXECUTABLE=../server/yats-server + +if [ "$#" != "2" ]; then + echo "Usage $0 <name> <start|stop>" + exit 1 +fi +instance=$1 +operation=$2 +PIDFILE=~/yats-${instance}.pid +if [ "$operation" = "stop" ]; then + PID2K=$(cat $PIDFILE) + kill -9 $PID2K && rm $PIDFILE + exit 0 +fi + +test -f $PIDFILE && echo PID file exist +test -f $PIDFILE && exit 1 + +export GIN_MODE=release +${EXECUTABLE} ${instance} & echo $! > $PIDFILE