質問

I've just setup nginx and unicorn. I start unicorn like this:

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

I've tried the various commands for stopping the unicorn but none of them work. I usually just restart the server and start unicorn again but this is very annoying.

EDIT

unicorn.rb file (/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;
}  
役に立ちましたか?

解決

This is what I do:

$ 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

If you don't want to have all this line, script it, like this:

/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

and then:

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

summon it each time calling:

$ /var/www/Web/unicorn_restart.sh

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top