I made some changes to my rails app, and tried to push the changes using my capistrano deploy task. It ran fine, and finished off by putting the restart.txt file in the tmp folder of the application. I then visited the site, immediately getting a 502 bad gateway error. I stopped nginx, and tried restarting. When I do, i simply get:
Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
When i run ps ax, several nginx worker processes are still running, but i can’t imagine that would be the issue. In case it helps, here’s my deploy script:
# $:.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
Found another post eventually that said to try running the netstat command with sudo:
sudo netstat -anltp | grep LISTENI was then able to find the PID using port 80, and kill it. It was one of the workers.