Commit 6f436b16 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos.cookbook: Check if pid file is not empty

  If pidfile is empty, the pgrep will fail forever until the pidfile
  is removed, so check if it exist and it is not empty.
parent 20280957
...@@ -156,10 +156,12 @@ class GenericBaseRecipe(object): ...@@ -156,10 +156,12 @@ class GenericBaseRecipe(object):
lines.append(dedent(""" lines.append(dedent("""
# Check for other instances # Check for other instances
pidfile=%s pidfile=%s
if [ -s $pidfile ]; then
if pid=`pgrep -F $pidfile -f "$COMMAND" 2>/dev/null`; then if pid=`pgrep -F $pidfile -f "$COMMAND" 2>/dev/null`; then
echo "Already running with pid $pid." echo "Already running with pid $pid."
exit 1 exit 1
fi fi
fi
echo $$ > $pidfile""" % shlex.quote(pidfile))) echo $$ > $pidfile""" % shlex.quote(pidfile)))
lines.append(dedent(''' lines.append(dedent('''
......
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