我刚刚设置了nginx和独角兽。我这样开始独角兽:
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;
}
答案 0 :(得分:2)
这就是我的所作所为:
$ 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