さくらのVPSにデプロイしようとしてunicoruの起動コードでエラーが出てしまい解決出来ないのでどなたかご教授お願いします。
エラーは以下になります。
[d6de6769] master failed to start, check stderr log for details (Backtrace restricted to imported tasks) cap aborted! SSHKit::Runner::ExecuteError: Exception while executing as panda@155.127.133.76: bundle exit status: 1 bundle stdout: master failed to start, check stderr log for details bundle stderr: Nothing written Caused by: SSHKit::Command::Failed: bundle exit status: 1 bundle stdout: master failed to start, check stderr log for details bundle stderr: Nothing written /home/vagrant/chibi/chibi/lib/capistrano/tasks/unicorn.rb:13:in `block in start_unicorn' /home/vagrant/chibi/chibi/lib/capistrano/tasks/unicorn.rb:12:in `start_unicorn' /home/vagrant/chibi/chibi/lib/capistrano/tasks/unicorn.rb:36:in `block (3 levels) in <top (required)>' Tasks: TOP => unicorn:start (See full trace by running task with --trace) The deploy has failed with an error: Exception while executing as panda@155.127.133.76: bundle exit status: 1 bundle stdout: master failed to start, check stderr log for details bundle stderr: Nothing written
bundler: failed to load command: unicorn (/usr/share/nginx/html/shared/bundle/ruby/2.3.0/bin/unicorn) ArgumentError: Already running on PID:18282 (or pid=/usr/share/nginx/html/current/tmp/pids/unicorn.pid is stale) /usr/share/nginx/html/shared/bundle/ruby/2.3.0/gems/unicorn-5.5.0/lib/unicorn/http_server.rb:207:in `pid=' /usr/share/nginx/html/shared/bundle/ruby/2.3.0/gems/unicorn-5.5.0/lib/unicorn/http_server.rb:139:in `start' /usr/share/nginx/html/shared/bundle/ruby/2.3.0/gems/unicorn-5.5.0/bin/unicorn:128:in `<top (required)>' /usr/share/nginx/html/shared/bundle/ruby/2.3.0/bin/unicorn:23:in `load' /usr/share/nginx/html/shared/bundle/ruby/2.3.0/bin/unicorn:23:in `<top (required)>'
unicornの起動確認
# ps -ef | grep unicorn | grep -v grep kinoko 18282 1 4 01:26 ? 00:00:03 unicorn master -c /usr/share/nginx/html/current/config/unicorn/production.rb -E production -D kinoko 18290 18282 0 01:27 ? 00:00:00 unicorn worker[0] -c /usr/share/nginx/html/current/config/unicorn/production.rb -E production -D kinoko 18293 18282 0 01:27 ? 00:00:00 unicorn worker[1] -c /usr/share/nginx/html/current/config/unicorn/production.rb -E production -D
エラー発生箇所は以下になります。
capistrano/tasks/unicorn.rb #unicornのpidファイル、設定ファイルのディレクトリを指定 namespace :unicorn do task :environment do #set :unicorn_pid, "#{current_path}/tmp/pids/unicorn.pid" set :unicorn_pid, "/usr/share/nginx/html/current/tmp/pids/unicorn.pid" #set :unicorn_config, "#{current_path}/config/unicorn/production.rb" set :unicorn_config, "/usr/share/nginx/html/current/config/unicorn/production.rb" end #unicornをスタートさせるメソッド def start_unicorn within current_path do # 12行目 execute :bundle, :exec, :unicorn, "-c #{fetch(:unicorn_config)} -E #{fetch(:rails_env)} -D" # 13行目 end end #unicornを停止させるメソッド def stop_unicorn execute :kill, "-s QUIT $(< #{fetch(:unicorn_pid)})" end #unicornを再起動するメソッド def reload_unicorn execute :kill, "-s USR2 $(< #{fetch(:unicorn_pid)})" end #unicronを強制終了するメソッド def force_stop_unicorn execute :kill, "$(< #{fetch(:unicorn_pid)})" end #unicornをスタートさせるtask desc "Start unicorn server" task start: :environment do on roles(:app) do start_unicorn # 36行目 end end #unicornを停止させるtask desc "Stop unicorn server gracefully" task stop: :environment do on roles(:app) do stop_unicorn end end #既にunicornが起動している場合再起動を、まだの場合起動を行うtask desc "Restart unicorn server gracefully" task restart: :environment do on roles(:app) do if test("[ -f #{fetch(:unicorn_pid)} ]") reload_unicorn else start_unicorn end end end #unicornを強制終了させるtask desc "Stop unicorn server immediately" task force_stop: :environment do on roles(:app) do force_stop_unicorn end end end
config deploy.rb set :unicorn_pid, "/usr/share/nginx/html/current/tmp/pids/unicorn.pid" set :unicorn_config_path, "/usr/share/nginx/html/current/config/unicorn/production.rb" set :unicorn_rack_env, 'production' namespace :deploy do desc 'Restart application' task :restart do invoke 'unicorn:restart' end
やったことは # kill -QUIT 18282 を実行して再度、デプロイしてみましたが同じエラーでした。
すでにunicornは起動しています。みたいなエラーだと思います。コードの記述ミスが原因だと思いますが、どこがいけないのかわからずいるので質問させて頂きました。
どなたかご教授の程、宜しくお願いします。
追記
プロセスの確認をしてみました。
# ps aux | grep unicorn kinoko 18282 0.0 5.4 457580 112368 ? Sl 01:26 0:04 unicorn master -c /usr/share/nginx/html/current/config/unicorn/production.rb -E production -D kinoko 18290 0.0 5.1 457448 105748 ? Sl 01:27 0:00 unicorn worker[0] -c /usr/share/nginx/html/current/config/unicorn/production.rb -E production -D kinoko 18293 0.0 5.1 457448 105032 ? Sl 01:27 0:00 unicorn worker[1] -c /usr/share/nginx/html/current/config/unicorn/production.rb -E production -D root 22024 0.0 0.0 112728 984 pts/0 S+ 12:29 0:00 grep --color=auto unicorn
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。