-
Notifications
You must be signed in to change notification settings - Fork 300
Conversation
e273faf
to
806d93a
Compare
HAPROXY_PIDS=$(pidof haproxy) | ||
haproxy -p $PIDFILE -f /marathon-lb/haproxy.cfg -D -sf $HAPROXY_PIDS | ||
if [ -n "${HAPROXY_RELOAD_SIGTERM_DELAY-}" ]; then | ||
sleep $HAPROXY_RELOAD_SIGTERM_DELAY && kill $HAPROXY_PIDS 2> /dev/null & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of &
at the end of this line? The sleep
runs in foreground and the kill
runs in background, is that intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe that's the case. Test it yourself:
$ sleep 5s && echo finished &
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&
and &&
are both posix shell pipeline separators. &&
executes sequentially until a nonzero status. &
executes in parallel. If the purpose of the code is to wait $HAPROXY_RELOAD_SIGTERM_DELAY
seconds before killing $HAPROXY_PIDS
that's what it'll do, if it's parent run
is still executing after the delay. If run
was for whatever reason killed/restarted in the meantime the kill won't be executed.
Edit: Actually the kill might get executed depending on how the parent reaps it's children. I.e. in case of this bash script whether shopt huponexit
is on or off. Likely also dependent on how runsv behaves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So sleep
and kill
are sequentially executed but kill
runs in parallel with the parent. I guess my real question is: How will this affect the overall time it takes to perform a zdd
deploy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right. If you set the delay to 5m
, then the old HAProxy processes will get reaped after 5 minutes, no matter what (and the deploy should proceed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I was hoping for zdd
to handle the killing of old HAProxy asynchronously but I don't know if this is doable because it might lead to a corrupted list of listeners.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this PR will only affect people who run MLB using the Docker image, or the built-in run script. I'll fix the haproxy.cfg thing in another PR.
806d93a
to
f1df667
Compare
f1df667
to
568ec34
Compare
This is to address issues #5, #71, #267, #276, and #318.