我的瘦服务器配置了 nginx,我的 ROR 应用程序正在它们上运行。
在我发布代码更新时运行 thin restart
会给我的应用程序带来一些停机时间。我试图弄清楚如何优雅地重启正在运行的 Thin 实例,但找不到好的解决方案。
有没有人能做到这一点?
最佳答案
# Restart just the thin server described by that config
sudo thin -C /etc/thin/mysite.yml restart
Nginx 将继续运行并代理请求。如果您将 Nginx 设置为使用多个上游服务器,例如
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;
}
...然后每个实例将依次重新启动,Nginx 将在其中一个代理关闭时自动路由请求。
关于ruby-on-rails - 如何优雅地重启 thin + nginx?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11657741/