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,9 +156,11 @@ class GenericBaseRecipe(object):
lines.append(dedent("""
# Check for other instances
pidfile=%s
if pid=`pgrep -F $pidfile -f "$COMMAND" 2>/dev/null`; then
echo "Already running with pid $pid."
exit 1
if [ -s $pidfile ]; then
if pid=`pgrep -F $pidfile -f "$COMMAND" 2>/dev/null`; then
echo "Already running with pid $pid."
exit 1
fi
fi
echo $$ > $pidfile""" % shlex.quote(pidfile)))
......
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