質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
nginx

nginixは軽量で高性能なwebサーバーの1つです。BSD-likeライセンスのもとリリースされており、あわせてHTTPサーバ、リバースプロキシ、メールプロキシの機能も備えています。MacOSX、Windows、Linux、上で動作します。

VPS

VPS(バーチャル・プライベート・サーバ)は、仮想化されたサーバをレンタルするサービスで、共有サーバでありながら専門サーバと同等の機能を果たします。物理的な専門サーバより安価で提供できるメリットがあります。

Capistrano

Rubyで書かれたサーバオーケストレーションで、複数のサーバでスクリプトを実行する際に用いられます。主な使用用途はWebアプリケーションのデプロイメントです。 アプリケーションのバージョンアップ自動化、およびデータベースの変更などもできます。

Q&A

解決済

1回答

986閲覧

Capistrano3+Nginx+unicornでunicornの起動のエラーが解決出来ずに困っています。ArgumentError: Already running on PID:18282 (o

koume

総合スコア458

nginx

nginixは軽量で高性能なwebサーバーの1つです。BSD-likeライセンスのもとリリースされており、あわせてHTTPサーバ、リバースプロキシ、メールプロキシの機能も備えています。MacOSX、Windows、Linux、上で動作します。

VPS

VPS(バーチャル・プライベート・サーバ)は、仮想化されたサーバをレンタルするサービスで、共有サーバでありながら専門サーバと同等の機能を果たします。物理的な専門サーバより安価で提供できるメリットがあります。

Capistrano

Rubyで書かれたサーバオーケストレーションで、複数のサーバでスクリプトを実行する際に用いられます。主な使用用途はWebアプリケーションのデプロイメントです。 アプリケーションのバージョンアップ自動化、およびデータベースの変更などもできます。

0グッド

0クリップ

投稿2019/05/06 16:38

編集2019/05/07 03:32

さくらの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

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

解決したわけではありませんが、VPS側のpidファイルを削除し、再度デプロイしたところArgumentErrorは
発生せず、べつのエラーが発生しました。
とりあえず、この質問についてはpidファイルを削除してデプロイ実行すると解決出来たことにします。

別のエラー発生
Errno::EADDRINUSE: Address already in use - connect(2) for /usr/share/nginx/html/current/tmp/sockets/.unicorn.sock

このエラーについても、自分で調べた後で解決出来なければ質問します。

投稿2019/05/07 04:52

koume

総合スコア458

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問