-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstop.sh
executable file
·47 lines (38 loc) · 1.02 KB
/
stop.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
42
43
44
45
46
47
#!/bin/bash
# Change directory to the one containing this script, which allows this script to be called from anywhere
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# We only run if the lock file exists
if [[ ! -e run/main.lock ]]
then
echo Servers not running.
exit 1
fi
# Set default configuration values (only the ones we need), then load configuration to override them as appropriate
BZLURPLYSRVPORT=5195
BZLUSRVPORT="5196 5197 5198"
if [[ -f config.txt ]]
then
source config.txt
fi
# Remove keepalive file so main script doesn't try to respawn the servers
rm run/main.keepalive 2>/dev/null
# Kill the servers
for PORT in $BZLUSRVPORT
do
kill `cat run/$PORT-pid.txt` 2>/dev/null
done
if [[ $BZLURPLYSRVPORT ]]
then
kill `cat run/$BZLURPLYSRVPORT-pid.txt` 2>/dev/null
fi
# Give the start script a few seconds to remove the lock file, then go ahead and do it
COUNTDOWN=5
while [[ $COUNTDOWN -gt 0 ]] && [[ -e run/main.lock ]]
do
sleep 1
: $((--COUNTDOWN))
done
if [[ -e run/main.lock ]]
then
rmdir run/main.lock
fi