【问题标题】:Unicorn: Start, Stop and Restart Centos 6独角兽:启动、停止和重启 Centos 6
【发布时间】:2014-05-11 18:14:59
【问题描述】:

我刚刚设置了 nginx 和 unicorn。我这样开始独角兽:

unicorn_rails -c /var/www/Web/config/unicorn.rb -D

我已经尝试了各种停止独角兽的命令,但都不起作用。我通常只是重新启动服务器并重新启动独角兽,但这很烦人。

编辑

unicorn.rb 文件(/var/www/Web/config/):

# Set the working application directory
# working_directory "/path/to/your/app"
working_directory "/var/www/Web"

# Unicorn PID file location
# pid "/path/to/pids/unicorn.pid"
pid "/var/www/Web/pids/unicorn.pid"

# Path to logs
# stderr_path "/path/to/log/unicorn.log"
# stdout_path "/path/to/log/unicorn.log"
stderr_path "/var/www/Web/log/unicorn.log"
stdout_path "/var/www/Web/log/unicorn.log"

# Unicorn socket
listen "/tmp/unicorn.Web.sock"
listen "/tmp/unicorn.Web.sock"

# Number of processes
# worker_processes 4
worker_processes 2

# Time-out
timeout 30

default.conf (/etc/nginx/conf.d/):

upstream app {
# Path to Unicorn SOCK file, as defined previously
server unix:/tmp/unicorn.Web.sock fail_timeout=0;
}

server {


listen 80;
server_name localhost;

# Application root, as defined previously
root /root/Web/public;

try_files $uri/index.html $uri @app;

location @app {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_pass http://app;
}

error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}  

【问题讨论】:

  • /etc/init.d/unicorn_Xxx 重载
  • 我得到这个结果:/etc/init.d/unicorn_Web: No such file or directory
  • 你应该用你的独角兽文件替换 unicorn_xxx 你用过 capistrano 吗?如果是,则使用 reload/stop/start 放置独角兽的路径
  • 我没有使用 capistrano 进行部署,但我在问题中包含了更多信息
  • 也粘贴你的 unicorn sh 文件

标签: ruby-on-rails ruby ruby-on-rails-4 nginx unicorn


【解决方案1】:

这就是我的工作:

$ for i in `ps awx | grep unico | grep -v grep | awk '{print $1;}'`; do kill -9 $i; done && unicorn_rails  -c /var/www/Web/config/unicorn.rb -D

如果您不想拥有所有这一行,请编写脚本,如下所示:

/var/www/Web/unicorn_restart.sh:

#!/bin/bash
for i in `ps awx | grep unicorn | grep -v grep | awk '{print $1;}'`; do 
    kill $i 
done
unicorn_rails  -c /var/www/Web/config/unicorn.rb -D

然后:

$ chmod +x /var/www/Web/unicorn_restart.sh

每次调用时召唤它:

$ /var/www/Web/unicorn_restart.sh

【讨论】:

    猜你喜欢
    • 2013-07-02
    • 2013-10-21
    • 1970-01-01
    • 2012-06-01
    • 2023-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多