Commit 78cb1683 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

stack/monitor: more robust httpd wrapper

This is a fixup of nexedi/slapos!1418
parent ffbc9bc2
......@@ -22,7 +22,7 @@ md5sum = 0540fc5cc439a06079e9e724a5a55a70
[template-monitor-httpd-wrapper]
_update_hash_filename_ = templates/template-monitor-httpd-wrapper.sh.in
md5sum = 45929a22527b71620555326f4dd78c34
md5sum = 0e2adaa78ba05fd80be3a88cb90499dc
[monitor-template-wrapper]
_update_hash_filename_ = templates/wrapper.in
......
......@@ -9,8 +9,8 @@ if [ -f "$pid_file" ]; then
pid=$(cat "$pid_file")
result=$(ps aux | grep "^\S*\s*$pid\s")
# The process with the specified PID is running
if [ -n "$result" ]; then
# The process with the specified PID is running
echo "there is a process running with the same pid"
# Get the command line of the process and replace null characters with spaces
cmdline=$(tr '\0' ' ' < "/proc/$pid/cmdline")
......@@ -21,6 +21,14 @@ if [ -f "$pid_file" ]; then
echo "The process is not running with the monitor_httpd_conf"
rm -f {{ pid_file }};
fi
else
# No process is running with this PID. If we do nothing, httpd should
# be able to start. However, we already experienced some case where
# httpd was not able to recover. For example, a thread with TID equal
# to PID would lead to a failure from httpd to start. So we "help"
# httpd by removing the file proactively.
echo "No process is running with PID $pid, removing the pid file"
rm -f {{ pid_file }};
fi
fi
......
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