我怎样才能优雅地重启瘦+ nginx?

Les*_*ial 5 ruby capistrano ruby-on-rails nginx thin

我的瘦服务器配置了nginx,我的ROR应用程序正在运行.

thin restart当我发布代码更新时运行会给我的应用程序带来一些停机时间.我试图想象如何优雅地重新启动正在运行的Thin实例,但我找不到一个好的解决方案.

有没有人能够做到这一点?

Phr*_*ogz 8

# Restart just the thin server described by that config
sudo thin -C /etc/thin/mysite.yml restart 
Run Code Online (Sandbox Code Playgroud)

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;
}
Run Code Online (Sandbox Code Playgroud)

...然后,每个实例将依次重新启动,如果它停止,Nginx将自动路由一个代理周围的请求.