2016-02-26 93 views
0

我一直在擊敗我的頭靠牆試圖弄清楚,我完全卡住了。我試圖部署一個處理域重定向的應用程序。它與我們的主Web應用程序一起運行,並具有一個將用戶從一個域重定向到另一個域的表。它是一個複雜的系統,但我不是最初的開發者,所以它有點落在我的腿上。它正在我們當前的生產服務器上運行,但我們正在轉向另一臺。我正在使用Capistrano將整個應用程序從我們的開發服務器移動到新的生產服務器。我們的應用程序的主要網絡端已被手動移動,似乎正常工作,但他們沒有複製這個網絡應用程序,當他們移動一切,所以現在我需要使用Capistrano來部署這個應用程序。獨角獸/ Nginx/Capistrano部署(服務器未啓動)

當我做一章部署生產,我收到此錯誤:如果我運行

unicorn 
在應用

2016-02-26 15:40:07 executing `deploy:restart' 
triggering after callbacks for `deploy:restart' 
* 2016-02-26 15:40:07 executing `unicorn:reload' 
* executing "sleep 3; kill -s USR2 `cat /u/apps/app/shared/pids/unicorn.pid`" 
servers: ["127.0.0.1"] 
[127.0.0.1] executing command 
** [out :: 127.0.0.1] kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec] 
** [out :: 127.0.0.1] 
command finished in 3294ms 
failed: "rvm_path=$HOME/.rvm $HOME/.rvm/bin/rvm-shell '[email protected]' -c 'sleep 3; kill -s USR2 `cat /u/apps/app/shared/pids/unicorn.pid`'" on 127.0.0.1 

/電流麒麟服務器啓動了,但我必須去domain.com:8080讓它起作用並重定向...我真的不知道還有什麼可以做的,我確定它有些愚蠢,但我看不見它。我認爲,也許有一個問題與Nginx,但我什麼也沒有看到。

Deploy.rb

set :stages, %w(staging production)¬ 

set :default_stage, 'production'¬ 
require 'capistrano/ext/multistage'¬ 
¬ 
set :application, "app"¬ 
set :repository, "[email protected]:app"¬ 
set :scm, :git¬ 
set :branch, 'master'¬ 
ssh_options[:forward_agent] = true¬ 
set :deploy_via, :remote_cache¬ 
set :ssh_options, { :forward_agent => true}¬ 
default_run_options[:pty] = true¬ 
¬ 
# RVM Setup¬ 
    gem 'sass-rails', '= 3.2.6'¬ 
#$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.¬ 
require "bundler/capistrano"¬ 
require "rvm/capistrano"▸ ▸ ▸ ▸ ▸ ▸ ▸ ▸ ▸ ▸ ▸ ▸ ▸ ▸ ▸ ⋅¬ 
set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"")¬ 
set :rvm_ruby_string, '[email protected]'¬                                   
set :rvm_type, :user¬ 
    before 'deploy', 'rvm:install_rvm' #install rvm on target¬ 
    before 'deploy', 'rvm:install_ruby' #install ruby on target¬ 
    before 'deploy:setup', 'rvm:install_rvm'¬ 
    before 'deploy:setup', 'rvm:install_ruby'¬ 
¬ 
⋅⋅⋅⋅¬ 
# Unicorn tasks from: http://blog.teachstreet.com/building-teachstreet/how-i-learned-to-stop-worrying-and-love-the-unicorn/¬ 
set :unicorn_pid, "#{shared_path}/pids/unicorn.pid"¬ 
namespace :unicorn do¬ 
    desc "start unicorn"¬ 
    task :start, :roles => :app, :except => { :no_release => true } do¬ 
    run "cd #{current_path} && bundle exec unicorn -C#{current_path}/config/unicorn-#{rails_env}.rb -E #{rails_env} -D"¬ 
    end¬ 

desc "stop unicorn"¬ 
task :stop, :roles => :app, :except => { :no_release => true } do¬ 
run " kill `cat #{unicorn_pid}`"¬ 
end¬ 
desc "graceful stop unicorn"¬ 
task :graceful_stop, :roles => :app, :except => { :no_release => true } do¬ 
run " kill -s QUIT `cat #{unicorn_pid}`"¬ 
end¬ 
desc "reload unicorn"¬ 
task :reload, :roles => :app, :except => { :no_release => true } do¬ 
run " sleep 3; kill -s USR2 `cat #{unicorn_pid}`"¬ 
end¬ 
⋅¬ 
after "deploy:restart", "unicorn:reload"¬ 
end¬ 
¬ 
#namespace :rvm do¬ 
# task :trust_rvmrc do¬ 
# run " 
rvm rvmrc trust #{release_path}"¬ 
# end¬ 
#▸after "deploy", "rvm:trust_rvmrc"¬ 
#end¬ 

nginx.conf

upstream unicorn { 
server unix:/u/apps/app/shared/unicorn.sock fail_timeout=0; 
} 

server { 
    listen 80; 

    # http://nginx.org/en/docs/http/server_names.html 
    # A special wildcard in the form 「.nginx.org」 can be used to match both the exact name 「nginx.org」 and the wildcard name 「*.nginx.org」. 
    server_name .domain.com; 

    client_max_body_size 4G; 

# ~2 seconds is often enough for most folks to parse HTML/CSS and 
# retrieve needed images/icons/frames, connections are cheap in 
# nginx so increasing this is generally safe... 
keepalive_timeout 5; 

# path for static files 
root /u/apps/app/current/public; 

# Prefer to serve static files directly from nginx to avoid unnecessary 
# data copies from the application server. 
# 
# try_files directive appeared in in nginx 0.7.27 and has stabilized 
# over time. Older versions of nginx (e.g. 0.6.x) requires 
# "if (!-f $request_filename)" which was less efficient: 
# http://bogomips.org/unicorn.git/tree/examples/nginx.conf?id=v3.3.1#n127 
try_files $uri/index.html $uri.html $uri @app; 

location @app { 
    # an HTTP header important enough to have its own Wikipedia entry: 
    # http://en.wikipedia.org/wiki/X-Forwarded-For 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 

    # enable this if and only if you use HTTPS, this helps Rack 
    # set the proper protocol for doing redirects: 
    # proxy_set_header X-Forwarded-Proto https; 

    # pass the Host: header from the client right along so redirects 
    # can be set properly within the Rack application 
    proxy_set_header Host $http_host; 

    # we don't want nginx trying to do something clever with 
    # redirects, we set the Host: header above already. 

proxy_redirect off; 

    # set "proxy_buffering off" *only* for Rainbows! when doing 
    # Comet/long-poll/streaming. It's also safe to set if you're using 
    # only serving fast clients with Unicorn + nginx, but not slow 
    # clients. You normally want nginx to buffer responses to slow 
    # clients, even with Rails 3.1 streaming because otherwise a slow 
    # client can become a bottleneck of Unicorn. 
    # 
    # The Rack application may also set "X-Accel-Buffering (yes|no)" 
    # in the response headers do disable/enable buffering on a 
    # per-response basis. 
    # proxy_buffering off; 

    proxy_pass http://unicorn; 
    } 

# Rails error pages 
error_page 500 502 503 504 /500.html; 
location = /500.html { 
    root /u/apps/app/current/public; 
    } 
} 

Unicorn.rb

# http://blog.teachstreet.com/building-teachstreet/how-i-learned-to-stop-worrying-and-love-the-unicorn/ 
worker_processes 6 
preload_app true 
timeout 180 

APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')) 

# Use RVM 
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm') 
    begin 
    rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME'])) 
    rvm_lib_path = File.join(rvm_path, 'lib') 
    $LOAD_PATH.unshift rvm_lib_path 
    require 'rvm' 
    RVM.use_from_path! APP_ROOT 
    rescue LoadError 
    raise "RVM ruby lib is currently unavailable." 
    end 
end 

# Use Bundler 
ENV['BUNDLE_GEMFILE'] = File.join(APP_ROOT, 'Gemfile') 
puts "BUNDLER_GEMFILE=#{ENV['BUNDLE_GEMFILE']}" 
require 'bundler/setup' 

# Setup directories 
working_directory APP_ROOT 
listen "/u/apps/app/shared/unicorn.sock", :backlog => 64 
#pid APP_ROOT + "/tmp/pids/unicorn.pid" 
pid "/u/apps/app/shared/pids/unicorn.pid" 
stderr_path APP_ROOT + "/log/unicorn.stderr.log" 
stdout_path APP_ROOT + "/log/unicorn.stdout.log" 

after_fork do |server, worker| 
    ActiveRecord::Base.establish_connection 
end 

before_fork do |server, worker| 
    ActiveRecord::Base.connection.disconnect! 

    #old_pid = RAILS_ROOT + '/tmp/pids/unicorn.pid.oldbin' 
    old_pid = '/u/apps/app/shared/pids/unicorn.pid.oldbin' 
    if File.exists?(old_pid) && server.pid != old_pid 
    begin 
     Process.kill("QUIT", File.read(old_pid).to_i) 
rescue Errno::ENOENT, Errno::ESRCH 
     # someone else did our job for us 
    end 
    end 
end 

回答

0

** [out :: 127.0.0.1] kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec] ** [out :: 127.0.0.1] 看起來像kill命令不起作用。