Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved the _start() method in the sysv initscript. Until now a sta… #433

Merged
merged 6 commits into from
May 19, 2017
Merged
Changes from 3 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
22 changes: 22 additions & 0 deletions templates/default/sysvinit.service.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
_start() {
touch $logfile
chown $user $logfile
echo "Starting consul"
start-stop-daemon --start --quiet --background \
--pidfile $pidfile<% unless @pid_file_external %> --make-pidfile<% end %> \
--chuid $user --chdir "<%= @directory %>" \
--startas /bin/bash -- -c "exec $exec <%= @daemon_options %> >> $logfile 2>&1"

_wait_for_listening
}

_stop() {
Expand Down Expand Up @@ -106,6 +109,25 @@ _status_q() {
_status >/dev/null 2>&1
}

_wait_for_listening() {
echo -n "Waiting for consul daemon to be listening..."
for i in `seq 1 30`; do
# if ! start-stop-daemon --quiet --stop --test --pidfile $pidfile --user $user; then
if ! _status_q; then

This comment was marked as outdated.

This comment was marked as outdated.

echo " FAIL: consul process died"
return 2
fi
if "$exec" info >/dev/null; then
echo " OK"
return 0
fi
echo -n .
sleep 1
done
echo " FAIL: consul process is alive, but is not listening."
return 2
}

case "$1" in
start)
_status_q && exit 0
Expand Down