Add System V Init script and systemd unit, update README.md
This commit is contained in:
64
contrib/reniced.init
Normal file
64
contrib/reniced.init
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
# Start/stop/restart reniced.
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: reniced
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Start the reniced service.
|
||||
# Description: Service that periodically checks and changes runtime niceness of given (by name) processes.
|
||||
### END INIT INFO
|
||||
|
||||
|
||||
# Start reniced:
|
||||
_start() {
|
||||
echo -n "Starting Reniced daemon: /usr/sbin/reniced"
|
||||
/usr/sbin/reniced
|
||||
echo
|
||||
}
|
||||
|
||||
# Stop reniced:
|
||||
_stop() {
|
||||
echo -n "Stopping Reniced daemon..."
|
||||
if [ -r /var/run/reniced.pid ]; then
|
||||
kill -HUP "$(cat /var/run/reniced.pid)"
|
||||
rm -f "/var/run/reniced.pid"
|
||||
else
|
||||
killall -HUP -q reniced
|
||||
fi
|
||||
echo
|
||||
}
|
||||
|
||||
# Restart renicedd:
|
||||
_restart() {
|
||||
_stop
|
||||
sleep 1
|
||||
_start
|
||||
}
|
||||
|
||||
# Check if reniced is running
|
||||
_status() {
|
||||
if [ -e /var/run/reniced.pid ]; then
|
||||
echo "reniced is running as pid $(cat /run/reniced.pid)."
|
||||
else
|
||||
echo "reniced is stopped."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
_start
|
||||
;;
|
||||
'stop')
|
||||
_stop
|
||||
;;
|
||||
'restart')
|
||||
_restart
|
||||
;;
|
||||
'status')
|
||||
_status
|
||||
;;
|
||||
*)
|
||||
echo "usage $0 start|stop|restart|status"
|
||||
esac
|
||||
Reference in New Issue
Block a user