Skip to content

Commit

Permalink
Poll Agent status when starting on Debian
Browse files Browse the repository at this point in the history
  • Loading branch information
elijahandrews committed Jul 18, 2013
1 parent 717a5fd commit 6403c68
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions packaging/datadog-agent-base-deb/datadog-agent.init
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,21 @@ case "$1" in
su $AGENTUSER -c "env LANG=POSIX $DOGSTATSDPATH start > /dev/null 2>&1"
fi

sleep 4 # wait for the services to start up
if check_status > /dev/null; then
log_end_msg 0
else
log_end_msg 1
fi
# check if the agent is running once per second for 10 seconds
retries=10
while [ $retries -gt 1 ]; do
if check_status > /dev/null; then
# We've started up successfully. Exit cleanly
log_end_msg 0
exit 0
else
retries=$(($retries - 1))
sleep 1
fi
done
# After 10 tries the agent didn't start. Report an error
log_end_msg 1
exit 1
;;
stop)
if [ -f $USE_SUPERVISOR ]; then
Expand Down

0 comments on commit 6403c68

Please sign in to comment.