39 lines
611 B
Bash
39 lines
611 B
Bash
#!/bin/bash
|
|
|
|
start_monitor() {
|
|
nohup cargo run --release > output.log 2>&1 &
|
|
sleep 1
|
|
echo "Monitor started"
|
|
}
|
|
|
|
stop_monitor() {
|
|
if [ -f /tmp/mtemp-monitor.pid ]; then
|
|
pid=$(cat /tmp/mtemp-monitor.pid)
|
|
echo "Stopping monitor with PID $pid"
|
|
kill $pid
|
|
rm /tmp/mtemp-monitor.pid
|
|
echo "Monitor stopped"
|
|
else
|
|
echo "Monitor is not running (PID file not found)"
|
|
fi
|
|
}
|
|
|
|
case "$1" in
|
|
start)
|
|
start_monitor
|
|
;;
|
|
stop)
|
|
stop_monitor
|
|
;;
|
|
restart)
|
|
stop_monitor
|
|
sleep 1
|
|
start_monitor
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|restart}"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|