again nohup

This commit is contained in:
Jorge Bolois 2024-02-03 15:01:29 +01:00
parent 094ba3631d
commit 55e0afe415
4 changed files with 39 additions and 10 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ Cargo.lock
**/*.rs.bk
*.pdb
/target
output.log

38
manage.sh Normal file
View File

@ -0,0 +1,38 @@
#!/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

View File

@ -1,5 +0,0 @@
#!/bin/bash
cargo run --release
sleep 1
echo "Monitor started"

View File

@ -1,5 +0,0 @@
#!/bin/bash
pkill mtemp-monitor
sleep 1
echo "Monitor stopped"