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

restarting supervisor fails #47

Open
JMLX42 opened this issue Aug 5, 2018 · 4 comments
Open

restarting supervisor fails #47

JMLX42 opened this issue Aug 5, 2018 · 4 comments

Comments

@JMLX42
Copy link

JMLX42 commented Aug 5, 2018

The current handler implementation fails "sometimes" because Ansible will not call:

service supervisor restart

but will call something like this instead:

service supervisor stop && service supervisor start

This will fail "sometimes" because supervisor programs (and supervisor itself) are not completely stopped when service supervisor stop returns. Then, when service supervisor start is called immediately, it will fail.

See this post: https://stackoverflow.com/questions/32738415/supervisor-fails-to-restart-half-of-the-time

It can be fixed by rewriting the restart handler this way:

- name: stop supervisor
  service:
    name: supervisor
    state: stopped
  listen: "restart supervisor"

- name: waiting for supervisor to be stopped
  wait_for:
    path: /var/run/supervisord.pid
    state: absent
    sleep: 5
  listen: "restart supervisor"

- shell: ps faux | grep supervisor

- name: start supervisor
  service:
    name: supervisor
    state: started
  listen: "restart supervisor"

Edit: the proposal above does not work as expected yet. I'll edit it when I can confirm it works.

Another solution might be to call service supervisor restart using the Ansible shell module.

@JMLX42
Copy link
Author

JMLX42 commented Aug 5, 2018

FYI this is the implementation of restart:

restart)
    echo -n "Restarting $DESC: "
    start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
	[ -n "$DODTIME" ] && sleep $DODTIME
	start-stop-daemon --start --quiet --pidfile $PIDFILE \
		--startas $DAEMON -- $DAEMON_OPTS
	echo "$NAME."
	;;

As you can see, it calls sleep $DODTIME with $DODTIME set to 5 (seconds) by default.
So supervisor expects a 5 seconds timeout between start and stop.

@JMLX42
Copy link
Author

JMLX42 commented Aug 5, 2018

I've updated my original proposal with the actual code to use.

Should I make a PR for this?

@JMLX42
Copy link
Author

JMLX42 commented Aug 5, 2018

PR ready to be merged: #48

@JMLX42
Copy link
Author

JMLX42 commented Aug 11, 2018

@tersmitten any chance this will be addressed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant