-
Notifications
You must be signed in to change notification settings - Fork 159
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
Consider adding ability to reload HAProxy #5
Comments
Does Haproxy reload config when it receives a signal like SIGHUP? |
Based on it's manpage, the answer is no. The key thing here is making sure we soft restart haproxy meaning that no connections get interrupted. The line I've provided allows for that. You can see why here. |
+1 |
1 similar comment
+1 |
Seeing how this would require supervisor or something more complex, I am hesitant to add it to the official image. I think the docker way would be to start a new container and start routing connections through that. |
+1 I understand the official image must be as clean as possible. However, not being able to reload configuration without breaking existing sessions will prevent many from using this image in production environment. |
I'm going to play with a bash script similar to below. I'll send a PR if I can get it to work.
|
Maybe we can be inspired by what @million12 wrote : It includes a inotify monitoring on the config file to reload automatically. |
+1 |
@bharrisau any luck on creating one? I might try to tackle it later today or thursday, unless you beat me to it. |
I went with the million12 repo instead, I got it working but it doesn't
|
+1 |
Reloading is a must, especially when using HAProxy for service discovery purposes. Using a inotify monitoring daemon would mean running multiple processes in the container. Consider using Unix Socket commands and putting that Might put something about this in the documentation so people can easily find it. |
Well, I might have to take this back. After some experimenting, it doesn't look like there is a Unix Socket command that will force HAProxy to re-evaluate it's config file. The reload command is great, but it does drop some (very few) packets. There is a lot of work in trying to achieve a "zero-downtime HAProxy reload"; so just codifying some kind of haproxy /reload might work for some, but not others. |
+1 |
Maybe we could start haproxy with |
I opened a PR #17 |
Hello, So how to do reload with the haproxy:1.6 version? |
From #17:
|
It does not work. Is the version with reload feature pushed to docker hub? |
USR2 does not work, HUP works. |
Should be pushed now! 👍
|
Sorry I have try HUP and it does not work I load also the config file as a volumen like this: docker run -it -p 443:443 -v /etc/ssl/private:/etc/ssl/private -v haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg --name proxy --net mynetwork am I doing something wrong? Like I try USR2, HUP and no luck |
@cemarta7 are you sure you've got the latest version of the |
I tried with haproxy:1.6-alpine and haproxy:1.6.. will try with latest and let you know in a couple of mins |
Tried with latest,alpine and nothing. but changes on the haproxy.cfg are not being display. this is my Dockerfile like should I load the volume with :ro? |
I think issue should be reopen. no luck with "docker kill --signal=HUP container_name" |
$ docker run -it -p 443:443 -v /etc/ssl/private:/etc/ssl/private -v haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg --name proxy --net mynetwork haproxy Assuming this is your run line, if you start the container and edit the file locally with something like vim, then the container will be unable to see the change: (moby/moby#15793 (comment)) |
Same problem here. I'm running HAProxy 1.6-alpine at the moment (tried 1.6 just before) with the following Docker command line:
Sending the HUP signal produces the following logs:
but it doesn't pick up the new configuration. Restarting the container altogether works though. |
Meh, OK, that was stupid of me. I replaced the bind mount with the following:
And that's much better. I'm using consul-template to regenerate the configuration file, and by default it erase the file and recreates a new one. Since the first version must be mounted somehow via my first |
How to reload haproxy with the new |
not sure if this relates to moby/moby#35048 |
It would be really nice if there was an easy way to reload the haproxy instance in this image via doing something like
docker exec -i -t haproxy /reload
whilst it's running so it isn't necessary to restart the container itself (which then executes the like ofhaproxy -f <config> -p <pidfile> -d -D -sf $(cat <pidfile>)
)However, I'm pretty sure the only way to do that is by providing a different init 1 process (i.e. supervisor) which may be unfavorable based on what these official repos/images are supposed to provide (which means I won't be too mad if this issue gets closed ;P)
The text was updated successfully, but these errors were encountered: