ref: 9bb99dda673271328bf65b4d4fa43b32875aa3a4
script/service.sh~
#! /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# Copyright: Paolo Lulli 2024 # cd $(dirname $0) EXECUTABLE=../server/yats-server instance="default" if [ "$#" = "2" ]; then operation=$2 else operation=$1 fi if [ "$#" < "1" ]; then echo "Usage $0 " 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