yats.git

ref: 89777a764361663ff609027a4848f29a7134fe05

script/service.sh


 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
#! /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
instance="default"
if [ "$#" = "2" ]; then
  instance=$1
  operation=$2
else
  operation=$1
fi
if [ "$#" -lt "1" ]; then
  echo "Usage $0 <name> <start|stop>"
  exit 1
fi

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
# NO nohup 
${EXECUTABLE} ${instance} >/dev/null 2>&1 & echo $! > $PIDFILE
#${EXECUTABLE} ${instance} 2>&1 & echo $! > $PIDFILE