forked from DougBarnes/Factory_Modbus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservicectl.sh
executable file
·48 lines (45 loc) · 1.12 KB
/
servicectl.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
45
46
47
48
#!/bin/bash
# This script is for a convienent way of controlling the pyservice
# get root permission
if [ $EUID != 0 ]; then
sudo -H "$0" "$@"
exit $?
fi
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
case $1 in
start)
sudo systemctl start pyController.service
sudo systemctl status pyController.service
;;
stop)
sudo systemctl stop pyController.service
;;
restart)
sudo systemctl restart pyController.service
;;
status)
sudo systemctl status pyController.service
;;
recent)
sudo journalctl -u pyController.service --since "5 minutes ago" -n 70
;;
log)
sudo journalctl -u pyController.service -n 70
;;
tail-log)
sudo journalctl -u pyController.service -n 10 -f
;;
tail-debuglog)
tail -f "$SCRIPT_DIR/pyController/logs/app.log"
;;
*)
echo "Arguments:
start - Start service
stop - Stop service
restart - Restart service
status - Status of service
recent - Displays recent logs within the last 5 minutes
log - Shows last 70 journal logs
tail-log - Tail service output
tail-debuglog - Tail debug log"
esac