-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrestart.sh
executable file
·45 lines (37 loc) · 934 Bytes
/
restart.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
#!/bin/bash
# file: restart.sh
# Usage: ./restart.sh [test|prod|all]
# Define server addresses
TEST_SERVER="[email protected]"
PROD_SERVER="[email protected]"
# Define the remote directory where the script is located
REMOTE_DIR="v2trading"
# Check for argument
if [ "$#" -ne 1 ]; then
echo "Usage: $0 [test|prod|all]"
exit 1
fi
# Function to restart a server
restart_server() {
local server=$1
echo "Connecting to $server to restart the Python app..."
ssh -t $server "cd $REMOTE_DIR && . ~/.bashrc && ./run.sh restart" # Sourcing .bashrc here
echo "Operation completed on $server."
}
# Select the server based on the input argument
case $1 in
test)
restart_server $TEST_SERVER
;;
prod)
restart_server $PROD_SERVER
;;
all)
restart_server $TEST_SERVER
restart_server $PROD_SERVER
;;
*)
echo "Invalid argument: $1. Use 'test', 'prod', or 'all'."
exit 1
;;
esac