I have my Thin servers configured with nginx and my ROR app is running on them.
Running thin restart
when I release an update to my code introduces some downtime to my application. I was trying to figure how to gracefully restart the running Thin instances but I could not find a good solution.
Has anyone been able to achieve this?
Restart Nginx only when making significant configuration updates, such as changing ports or interfaces. This command will force shut down all worker processes.
# Restart just the thin server described by that config
sudo thin -C /etc/thin/mysite.yml restart
Nginx will continue running and proxying requests. If you have your Nginx set to use multiple upstream servers, e.g.
server {
listen 80;
server_name myapp.mysite.com;
# ...
location / {
try_files $uri $uri/index.html /cache$uri.html $uri.html @proxy;
}
location @proxy {
proxy_pass http://myapp.rails;
}
}
upstream myapp.rails {
server 127.0.0.1:9001 max_fails=1 fail_timeout=10s;
server 127.0.0.1:9002 max_fails=1 fail_timeout=10s;
server 127.0.0.1:9003 max_fails=1 fail_timeout=10s;
}
…then each instance will be restarted in turn and Nginx will automatically route requests around one of the proxies if it's down.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With