Skip to content
This repository has been archived by the owner on Jan 23, 2020. It is now read-only.

[init] add optional client deregisration on stop #148

Merged
merged 2 commits into from
Jan 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions sensu_configs/init.d/sensu-service
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ wait_for_stop() {
return $stopped
}

deregister_client() {
log_action_msg "Deregistering sensu-client"
echo "{ \"name\": \"api_call\", \"output\": \"delete\", \"process\": \"init\", \"user\": \"root\", \"status\": 1, \"handler\": \"${CLIENT_DEREGISTER_HANDLER}\"}" > \
/dev/tcp/localhost/3030
}

start() {
log_daemon_msg "Starting $sensu_service"

Expand Down Expand Up @@ -235,6 +241,9 @@ start() {
}

stop() {
if [ "x$CLIENT_DEREGISTER_ON_STOP" = "xtrue" ]; then
deregister_client
fi
log_daemon_msg "Stopping $sensu_service"

# try pgrep
Expand Down