-
Notifications
You must be signed in to change notification settings - Fork 0
/
start
34 lines (28 loc) · 978 Bytes
/
start
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
#!/bin/bash
# run python server/core.py
# python3 server/core.py
# this shell script is a monitor that check whether this git repo need pull
# check every 10 seconds
# logic:
# 1. this script will spawn a child process: python3 server/core.py and handle its output and control
# 2. this script it self will check the git repo status every 10 seconds that if we need to pull
# 3. if we need to pull, we will kill the child process and pull the repo and restart the child process
# start the child process
npx kill-port 3332
python server/core.py &
child_pid=$!
echo "child process id: $child_pid"
# check the git repo status every 10 seconds
while true; do
# check if we need to pull
git fetch
if [ $(git rev-parse HEAD) != $(git rev-parse @{u}) ]; then
echo "need to pull! quitting $child_pid and restart"
kill $child_pid
git pull
npx kill-port 3332
python server/core.py &
child_pid=$!
fi
sleep 10
done