触摸tmp / restart.txt后,Phusion乘客nginx坏网关

时间:2011-10-18 21:28:14

标签: nginx ruby-on-rails-3.1 passenger

我对rails应用程序进行了一些更改,并尝试使用我的capistrano部署任务来推送更改。它运行正常,并通过将restart.txt文件放在应用程序的tmp文件夹中来完成。然后我访问了该站点,立即得到502错误的网关错误。我停止了nginx,并尝试重新启动。当我这样做时,我得到:

Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

当我运行ps ax时,几个nginx工作进程仍在运行,但我无法想象会出现问题。如果它有帮助,这是我的部署脚本:

# $:.unshift(File.expand_path('./lib', ENV['rvm_path']))

# require 'rvm/capistrano'
require 'bundler/capistrano'

# set :rvm_ruby_string, 'ruby-1.9.2-p290@global'
# set :rvm_type, :user

set :default_environment, {
  'PATH' => "/home/user/.rvm/gems/ruby-1.9.2-p290/bin:/home/user/.rvm/bin:/home/user/.rvm/ruby-1.9.2-p290/bin:$PATH",
  'RUBY_VERSION' => 'ruby 1.9.2',
  'GEM_HOME'     => '/home/user/.rvm/gems/ruby-1.9.2-p290',
  'GEM_PATH'     => '/home/user/.rvm/gems/ruby-1.9.2-p290',
  'BUNDLE_PATH'  => '/home/user/.rvm/gems/ruby-1.9.2-p290'  # If you are using bundler.
}

set :application, "StarCraftZen"
set :repository,  "githubrepourl"
set :user, "user"
set :scm_username, "user"
set :use_sudo, false
default_run_options[:pty] = true

set :scm, :git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`

set :deploy_to, "/home/user/app/"

role :web, "myapp.com"                         # Your HTTP server, Apache/etc
role :app, "myapp.com"                          # This may be the same as your `Web` server
role :db,  "myapp.com", :primary => true # This is where Rails migrations will run

load 'deploy/assets'

namespace :deploy do
  #desc "deploy the precompiled assets"
  #task :deploy_assets, :except => { :no_release => true } do
  #  run "cd #{release_path} && rm -rf public/assets/*"
  #  run "cd #{release_path} && RAILS_ENV=production bundle exec rake assets:precompile"
  #end

  desc "Restart nginx"
  task :restart do
    run "touch /home/user/app/current/tmp/restart.txt"
  end
end

1 个答案:

答案 0 :(得分:0)

发现另一篇帖子最终说要尝试用sudo运行netstat命令:

sudo netstat -anltp | grep LISTEN

然后我能够使用端口80找到PID并将其终止。这是工人之一。