-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathppnctl
More file actions
executable file
·106 lines (82 loc) · 2.63 KB
/
ppnctl
File metadata and controls
executable file
·106 lines (82 loc) · 2.63 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash
# Function to display help message
show_help() {
echo "Usage:"
echo " $0 run <cmd> [<duration>]"
echo " $0 ls"
exit 1
}
# Function to kill a process based on a PID file
kill_process_from_pidfile() {
local pid_file=$1
# Check if the PID file exists
if [ -f "$pid_file" ]; then
# Read the PID from the file
local pid=$(cat "$pid_file")
# Check if the process with this PID is running and kill it
if kill -0 "$pid" > /dev/null 2>&1; then
echo "Process $pid is running. Attempting to kill it..."
kill "$pid"
# Optional: Remove the PID file after killing the process
rm "$pid_file"
else
echo "Process $pid not found."
fi
else
echo "PID file $pid_file does not exist."
fi
}
# Check if at least one argument is provided
if [ $# -lt 1 ]; then
echo "Error: Command not specified."
show_help
fi
# Capture the current directory
CURRENT_DIR=$(pwd)
# Main command handling
case "$1" in
serve)
# run the 3 processes
#echo "starting IPC server"
#python3 -m Matrix.driver.executor --scheduler > server.log 2> server_err.log &
#echo "server started"
#echo "starting Server "
#python3 -m Matrix.driver --scheduler --listen&> "${CURRENT_DIR}/executor.log" & echo $! > "${CURRENT_DIR}/executor.pid"
#echo "server started"
echo "starting API "
python3 -m Matrix.api.server &> "${CURRENT_DIR}/server.log" & echo $! > "${CURRENT_DIR}/api.pid"
echo "server started"
sleep 2
echo "starting UI "
cd pixel-pulse-neo-client ; npm start &> "${CURRENT_DIR}/ui.log" & echo $! > "${CURRENT_DIR}/ui.pid"
echo "server started"
;;
stop)
#kill_process_from_pidfile "${CURRENT_DIR}/ui.pid"
killall -9 node
kill_process_from_pidfile "${CURRENT_DIR}/api.pid"
;;
run)
# Default value for duration
duration=200
# Check if command is provided
if [ -z "$2" ]; then
echo "Error: 'run' command requires a cmd argument."
show_help
fi
# Check if duration is provided
if [ -n "$3" ]; then
duration="$3"
fi
# Calling the Python script for 'run'
python3 -m Matrix.driver.executor -c "$2" -d "$duration"
;;
ls)
# Calling the Python script for 'ls'
python3 -m Matrix.driver.executor -l
;;
*)
echo "Error: Unknown command '$1'."
show_help
;;
esac