-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
46 lines (35 loc) · 832 Bytes
/
Copy pathrun.sh
File metadata and controls
46 lines (35 loc) · 832 Bytes
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
#!/bin/bash
base_path=$PWD
interpreter="python3"
service="${base_path}/server.py"
set -e # Exit if any command fails
# Install python pip libraries
install_dependencies(){
echo "Installing python libraries from pip3..."
# apt-get install python3-pip
pip3 install -r "${base_path}/requirements.txt"
echo "Installed dependencies..."
}
start_process(){
$interpreter $service &
}
stop_process(){
echo "Killing process $(basename $service)"
pkill -1 -f `basename $service` || true
}
if [[ "$1" == "stop" ]]; then
stop_process
echo "Process killed..."
exit 0
fi
if [[ "$1" == "start" ]]; then
echo "Process starting..."
start_process
exit 0
fi
if [[ "$1" == "install" ]]; then
echo "Installation started..."
install_dependencies
exit 0
fi
echo "Command not found"