Reputation: 1484
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?
Upvotes: 5
Views: 5494
Reputation: 303361
# 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.
Upvotes: 8