-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_remixd_with_hardhat.sh
More file actions
69 lines (59 loc) · 1.7 KB
/
start_remixd_with_hardhat.sh
File metadata and controls
69 lines (59 loc) · 1.7 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
#!/bin/bash
# Define the processes to run
PROCESSES=(
"remixd -s ./ --remix-ide https://remix.ethereum.org"
"firefox https://remix.ethereum.org"
"npx hardhat node"
)
# File to store PIDs
PID_FILE="process_ids.txt"
# Function to start processes
start_processes() {
echo "Starting processes..."
for process in "${PROCESSES[@]}"; do
nohup $process > "${process%% *}.log" 2>&1 &
echo $! >> $PID_FILE
done
echo "Processes started with PIDs:"
cat $PID_FILE
}
# Function to kill processes
kill_processes() {
echo "Initiating shutdown of processes..."
if [ -f "$PID_FILE" ]; then
while read -r pid; do
if ps -p $pid > /dev/null; then
kill $pid
echo "Sent SIGTERM to process with PID: $pid"
# Wait for a short period to allow the process to terminate gracefully
sleep 3
# Check if the process is still running
if ps -p $pid > /dev/null; then
echo "Process with PID $pid did not terminate. Sending SIGKILL..."
kill -9 $pid # Force kill if it didn't shut down gracefully
else
echo "Process with PID $pid terminated gracefully."
fi
else
echo "Process with PID $pid is not running."
fi
done < "$PID_FILE"
rm -f "$PID_FILE"
rm -f *.log
else
echo "No PID file found."
fi
}
# Main script logic
case "$1" in
start)
start_processes
;;
stop)
kill_processes
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
;;
esac