Commit 99cbeed5 authored by Adam Wujek's avatar Adam Wujek 💬

userspace/rootfs_override: make monit to start from inittab

When monit is started from inittab instead of script /etc/init.d/monit.sh
it will be respawned after its crash.
Support stopping/starting monit by /etc/init.d/monit.sh
To stop monit, STOP signal is sent to it. By this, init will not respawn monit,
because it is still present in process' list.
Add disabling monit in dot-config by option CONFIG_MONIT_DISABLE.
When monit is disabled by dot-config, monit.sh will sleep forever, to
satisfy init and prevent respawning
Update dot-config items in user-manual.

Include only *.conf instead of all files from /etc/monit.d/.
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 18ea681a
......@@ -471,3 +471,13 @@ config WRSAUXCLK_PPSHIFT
endmenu
menu "Developer options"
config MONIT_DISABLE
bool "Disable monit"
default n
help
Disable monit to prevent processes' restarts. It may be useful for
development.
endmenu
......@@ -551,6 +551,12 @@ value is changed by the web interface, proper action is taken.
the chosen name is expected to be installed in the @sc{wrs}
filesystem.
@item CONFIG_MONIT_DISABLE
Disable monitoring of running processes by monit. Monit by default
re spawns processes that have died. This option is useful mostly during
development.
@end table
@c ==========================================================================
......
#!/bin/sh
# start monit
/usr/bin/monit
# script to be run directly from init
dotconfig=/wr/etc/dot-config
monit_pid=/var/run/monit.pid
start() {
# to start monit, first kill monit running/stopped previously, init will
# take care of starting it again
if [ -f $monit_pid ]; then
kill -9 `cat $monit_pid`
else
echo "Unable to find monit's pid"
exit 1
fi
}
stop() {
echo "Stopping monit"
# Stop monit by sending STOP singal to it. Killing monit will make init
# to start another instance of monit.
if [ -f $monit_pid ]; then
kill -STOP `cat $monit_pid`
else
echo "Unable to find monit's pid"
exit 1
fi
}
restart() {
echo "Restarting monit"
# invoke start
start
}
loop_forever() {
# Save pid of current script as monit's (used by start function).
echo $$ > $monit_pid
# sleep forever
while true; do sleep 10000; done
}
init() {
# First, read dot-config to know if we shall start monit
if [ -f $dotconfig ]; then
. $dotconfig
else
echo "dot-config not found! Don't start monit"
loop_forever
fi
if [ -z "$CONFIG_MONIT_DISABLE" ]; then
echo "Start monit"
# start monit
/usr/bin/monit
else
echo "Monit disabled in dot-config"
loop_forever
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
init)
init
;;
*)
echo $"Usage: $0 {start|stop|restart|init}"
exit 1
;;
esac
......@@ -23,6 +23,7 @@
# now run any rc scripts
::sysinit:/etc/init.d/rcS
::respawn:/etc/init.d/monit.sh init
# Put a getty on the serial port
ttyGS0::respawn:/bin/ash --login
......
......@@ -14,9 +14,11 @@
## Global section
###############################################################################
##
## Start Monit in the background (run as a daemon):
#
set daemon 10 # check services at 10 seconds intervals
# run from init
set init
#if "set init" don't run as daemon. "set daemon" only specify interval
set daemon 10 # check services at 10 seconds intervals,
# with start delay 240 # optional: delay the first check by 4-minutes (by
# # default Monit check immediately after Monit start)
#
......@@ -54,5 +56,5 @@ set statefile /var/monit/monit.state
## It is possible to include additional configuration parts from other files or
## directories.
#
include /etc/monit.d/*
include /etc/monit.d/*.conf
#
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment