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

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

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

Unicornは、汎用のRackアプリケーションサーバ。RackとWebサーバーの機能を併せ持ちます。レスポンス処理や、Nginx単体がRackの機能をサポートしていない事から、一般的にはNginx+Unicorn+Railsの構成を取って用います。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Q&A

解決済

2回答

3762閲覧

unicorn railsコマンド実行時に、Already running on PID:〜 (or pid=/var/www/アプリ名/tmp/pids/unicorn.pi)のエラーが出た。

shimataroo

総合スコア1

unicorn

Unicornは、汎用のRackアプリケーションサーバ。RackとWebサーバーの機能を併せ持ちます。レスポンス処理や、Nginx単体がRackの機能をサポートしていない事から、一般的にはNginx+Unicorn+Railsの構成を取って用います。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

0グッド

0クリップ

投稿2021/01/10 13:06

編集2021/01/12 09:27

前提・実現したいこと

Railsのアプリ開発においてAWSでデプロイを行っており、Capistiranoでの自動デプロイまで完了しています。
しかし、このままだとURLがIPアドレスのため、「https://...」となるように、
HTTP通信とSSL認証まで行いたいと考えています。
現在の状況として、ドメインを取得し、Nginxの設定変更(server nameをIPアドレス→ドメイン名)、
unicornの停止確認まで問題なく進んでいます。

発生している問題・エラーメッセージ

「unicorn rails」コマンドを実行した時に、以下のエラーが表示されました。 ※アプリ名「match-you」

[ec2-user@ip-172-31-38-172 match-you]$ bundle exec unicorn_rails -c /var/www/rails/match-you/config/unicorn.conf.rb -D -E production bundler: failed to load command: unicorn_rails (/home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails) Errno::ENOENT: No such file or directory @ rb_sysopen - /var/www/rails/match-you/config/unicorn.conf.rb /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:84:in `read' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:84:in `reload' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:77:in `initialize' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:77:in `new' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:77:in `initialize' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `new' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `<top (required)>' /home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails:23:in `load' /home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails:23:in `<top (required)>' master failed to start, check stderr log for details

該当のソースコード

ターミナルのみでの作業のため同上となります。

試したこと

「check stderr log for details」のメッセージがあるので、lessコマンドを実行

[ec2-user@ip-172-31-38-172 match-you]$ less log/unicorn.stderr.log /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:205:in `pid=': Already running on PID:11935 (or pid=/var/www/match-you/tmp/pids/unicorn.pid is stale) (ArgumentError) from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:137:in `start' from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `<top (required)>' from /home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails:23:in `load' from /home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails:23:in `<main>' I, [2021-01-08T11:25:46.370087 #11935] INFO -- : reaped #<Process::Status: pid 11943 exit 0> worker=0 I, [2021-01-08T11:25:46.370223 #11935] INFO -- : master complete I, [2021-01-08T11:27:15.438576 #12119] INFO -- : Refreshing Gem list I, [2021-01-08T11:27:16.769719 #12119] INFO -- : listening on addr=0.0.0.0:3000 fd=9 I, [2021-01-08T11:27:16.774532 #12119] INFO -- : master process ready I, [2021-01-08T11:27:16.778082 #12127] INFO -- : worker=0 ready I, [2021-01-08T12:18:19.503694 #12119] INFO -- : reaped #<Process::Status: pid 12127 exit 0> worker=0 I, [2021-01-08T12:18:19.504358 #12119] INFO -- : master complete I, [2021-01-08T12:18:52.167629 #12614] INFO -- : Refreshing Gem list I, [2021-01-08T12:18:53.952263 #12614] INFO -- : listening on addr=/var/www/match-you/tmp/sockets/unicorn.sock fd=9 I, [2021-01-08T12:18:53.960691 #12614] INFO -- : master process ready I, [2021-01-08T12:18:53.964333 #12622] INFO -- : worker=0 ready I, [2021-01-08T13:39:20.944559 #12614] INFO -- : reaped #<Process::Status: pid 12622 exit 0> worker=0 I, [2021-01-08T13:39:20.944684 #12614] INFO -- : master complete

「PID=11935が既に動いているor古い」とあるため、まずは現在のプロセスを確認しました。

[ec2-user@ip-172-31-38-172 match-you]$ ps aux | grep unicorn ec2-user 5261 0.0 0.0 119436 924 pts/0 S+ 12:34 0:00 grep --color=auto unicorn

「11935」が表示されないため、killmコマンドを実行できず。
PIDが「既に動いている」のではなく「古い」のではと思い、tmpフォルダのpidsフォルダ内の
unicorn.piというファイルが悪さをしている可能性も考えたのですが、
そもそも上記ファイルの存在を確認できませんでした。

これ以上の打ち手分からず質問させて頂いております。
初質問のため回答頂くにあたり不足点もあるかと思われます。
抜けている視点や他に試した方が良いことなどご教示頂けますと幸いです。

その他、効果有無は分からなかったのですが以下も実行致しました(いずれも効果なし)。
・ローカル、リモート環境での差分の有無確認(git push origin master, git pull origin masterの実行)
・インスタンスの再起動
・ターミナルの再起動

補足情報(FW/ツールのバージョンなど)

ruby 2.6.5
rails 6.0.0
unicorn 5.4.1

unicorn.rb ※自動デプロイまではスクールのカリキュラムを参考に「unicorn.rb」ファイルで進めていました。ドメイン取得以降は別の記事を参照していたため、unicorn.conf.rbコマンドで実行してしまっていました。。

unicorn

1#サーバ上でのアプリケーションコードが設置されているディレクトリを変数に入れておく 2app_path = File.expand_path('../../../', __FILE__) # 「../」が一つ増えている 3 4#アプリケーションサーバの性能を決定する 5worker_processes 1 6 7#アプリケーションの設置されているディレクトリを指定 8working_directory "#{app_path}/current" # 「current」を指定 9 10#Unicornの起動に必要なファイルの設置場所を指定 11pid "#{app_path}/shared/tmp/pids/unicorn.pid" # 「shared」の中を参照するよう変更 12 13#ポート番号を指定 14listen "#{app_path}/shared/tmp/sockets/unicorn.sock" # 「shared」の中を参照するよう変更 15 16#エラーのログを記録するファイルを指定 17stderr_path "#{app_path}/shared/log/unicorn.stderr.log" # 「shared」の中を参照するよう変更 18 19#通常のログを記録するファイルを指定 20stdout_path "#{app_path}/shared/log/unicorn.stdout.log" # 「shared」の中を参照するよう変更 21 22#Railsアプリケーションの応答を待つ上限時間を設定 23timeout 60 24 25#以下は応用的な設定なので説明は割愛 26 27preload_app true 28GC.respond_to?(:copy_on_write_friendly=) && GC.copy_on_write_friendly = true 29 30check_client_connection false 31 32run_once = true 33 34before_fork do |server, worker| 35 defined?(ActiveRecord::Base) && 36 ActiveRecord::Base.connection.disconnect! 37 38 if run_once 39 run_once = false # prevent from firing again 40 end 41 42 old_pid = "#{server.config[:pid]}.oldbin" 43 if File.exist?(old_pid) && server.pid != old_pid 44 begin 45 sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU 46 Process.kill(sig, File.read(old_pid).to_i) 47 rescue Errno::ENOENT, Errno::ESRCH => e 48 logger.error e 49 end 50 end 51end 52 53after_fork do |_server, _worker| 54 defined?(ActiveRecord::Base) && ActiveRecord::Base.establish_connection 55end

deploy

1# capistranoのバージョンを記載。固定のバージョンを利用し続け、バージョン変更によるトラブルを防止する 2lock '3.15.0' 3 4# Capistranoのログの表示に利用する 5set :application, 'match-you' 6 7# どのリポジトリからアプリをpullするかを指定する 8set :repo_url, 'git@github.com:yutaro-kugishima/match-you.git' 9 10# バージョンが変わっても共通で参照するディレクトリを指定 11set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system', 'public/uploads') 12 13set :rbenv_type, :user 14set :rbenv_ruby, '2.6.5' #カリキュラム通りに進めた場合、’2.6.5’ です 15 16# どの公開鍵を利用してデプロイするか 17set :ssh_options, auth_methods: ['publickey'], 18 keys: ['~/.ssh/sample.pem'] 19 20# プロセス番号を記載したファイルの場所 21set :unicorn_pid, -> { "#{shared_path}/tmp/pids/unicorn.pid" } 22 23# Unicornの設定ファイルの場所 24set :unicorn_config_path, -> { "#{current_path}/config/unicorn.rb" } 25set :keep_releases, 5 26 27# デプロイ処理が終わった後、Unicornを再起動するための記述 28after 'deploy:publishing', 'deploy:restart' 29namespace :deploy do 30 task :restart do 31 invoke 'unicorn:restart' 32 end 33end

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

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

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

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

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

yu_1985

2021/01/10 15:44

> PID=11935が既に動いているor古い」 そのログが出ているのは、unicorn_railsを実行するよりも前の時間ではないでしょうか? 直近でunicorn_railsを実行したと思われる時間帯のログをきちんと確認しましょう。 実行時のエラーに > Errno::ENOENT: No such file or directory @ rb_sysopen - /var/www/rails/match-you/config/unicorn.conf.rb と出ていますが、このパスにunicorn.conf.rbは存在して、かつ読み取り可能な状態になっていますか?
shimataroo

2021/01/10 23:18 編集

コメント頂きありがとうございます。長文となってしまい申し訳ございません。 >そのログが出ているのは、unicorn_railsを実行するよりも前の時間ではないでしょうか? >直近でunicorn_railsを実行したと思われる時間帯のログをきちんと確認しましょう。 先ほど再度unicorn_railsを実行しlessコマンドで詳細確認致しました(以下となります)。 「shift」+Gで一番下までスクロールしておりますので最新のログかと思われるのですが、、 確かに時間帯としては「11:25:46→PID=11935」で、「13:39:20→PID=12614」と異なっている点(最新のログではPID=11935が存在していない?)は違和感を覚えております。 ``` /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:205:in `pid=': Already running on PID:11935 (or pid=/var/www/match-you/tmp/pids/unicorn.pid is stale) (ArgumentError) from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:137:in `start' from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `<top (required)>' from /home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails:23:in `load' from /home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails:23:in `<main>' I, [2021-01-08T11:25:46.370087 #11935] INFO -- : reaped #<Process::Status: pid 11943 exit 0> worker=0 I, [2021-01-08T11:25:46.370223 #11935] INFO -- : master complete I, [2021-01-08T11:27:15.438576 #12119] INFO -- : Refreshing Gem list I, [2021-01-08T11:27:16.769719 #12119] INFO -- : listening on addr=0.0.0.0:3000 fd=9 I, [2021-01-08T11:27:16.774532 #12119] INFO -- : master process ready I, [2021-01-08T11:27:16.778082 #12127] INFO -- : worker=0 ready I, [2021-01-08T12:18:19.503694 #12119] INFO -- : reaped #<Process::Status: pid 12127 exit 0> worker=0 I, [2021-01-08T12:18:19.504358 #12119] INFO -- : master complete I, [2021-01-08T12:18:52.167629 #12614] INFO -- : Refreshing Gem list I, [2021-01-08T12:18:53.952263 #12614] INFO -- : listening on addr=/var/www/match-you/tmp/sockets/unicorn.sock fd=9 I, [2021-01-08T12:18:53.960691 #12614] INFO -- : master process ready I, [2021-01-08T12:18:53.964333 #12622] INFO -- : worker=0 ready I, [2021-01-08T13:39:20.944559 #12614] INFO -- : reaped #<Process::Status: pid 12622 exit 0> worker=0 I, [2021-01-08T13:39:20.944684 #12614] INFO -- : master complete (END) ``` >実行時のエラーに > Errno::ENOENT: No such file or directory @ rb_sysopen - /var/www/rails/match-you/config/unicorn.conf.rb >と出ていますが、このパスにunicorn.conf.rbは存在して、かつ読み取り可能な状態になっていますか? ファイル名を改めて確認致しました所、「unicorn.conf.rb」ではなく「unicorn.rb」でした。申し訳ございません。コマンドを以下のように修正して実行したのですが、同様のエラーメッセージが表示されてしまいました。unicorn.rbファイルは問題なく開いて編集できる状態ですので、読み取り可能な状態なのではと考えております。 ``` $ bundle exec unicorn_rails -c /var/www/rails/match-you/config/unicorn.conf.rb -D -E production ``` ``` bundler: failed to load command: unicorn_rails (/home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails) Errno::ENOENT: No such file or directory @ dir_s_chdir - /var/www/current ``` さらに、ファイル名を「unicorn.conf.rb」に変更して、「git push origin master」と「git pull origin master」コマンド実行後に、再度unicorn_railsを実行しても同様のエラーが吐かれてしまっている状況です。 AWSに関して、始めてのチャットでの質問ということで至らない点もあるかと思うのですが、ご返信頂ければ幸いです。
yu_1985

2021/01/11 12:13

unicorn云々は過去のログなので関係ないと考えています。 恐らく現状はそもそもエラーでunicornを立ち上げられてないのでは? > unicorn.conf.rb」ではなく「unicorn.rb」でした それならコマンドで参照させているパスを修正しなければならないのでは。 下記でやってみてください。 bundle exec unicorn_rails -c /var/www/rails/match-you/config/unicorn.rb -D -E production
shimataroo

2021/01/11 12:30

返信頂きありがとうございます。 自分でも、そもそもエラーが原因なのでは?と思い始めてきました。 上記コマンドを実行してみたのですが、同じエラーが出てしまいました、、
yu_1985

2021/01/11 12:46

>「shift」+Gで一番下までスクロールしておりますので ということは、直近立ち上げようとしたときにはそのログにはエラーが出ていないということになりますが…。 ファイルの配置パスはたしかにこの通りですか? /var/www/rails/match-you/config/unicorn.rb
shimataroo

2021/01/11 13:15

EC2でアプリまでの移動は「cd /var/www/match-you」コマンドを実行していますので、 「cd /var/www/match-you/config/unicorn.rb」となります。ただし、unicorn_railsコマンド実行時に、パス名からrailsを抜いても同様のエラーが出てしまっている状態で、余計に混乱してしまっております。。
yu_1985

2021/01/11 16:54

unicorn.rbを見るとcurrentディレクトリの下に配置することを前提にconfigを書いているように見えるのですが…。 /var/www/match-you の配下で`ls -l` コマンドを打って結果を貼ってくれませんか? その下に何か見るべきディレクトリがあればそこもお願いします。
shimataroo

2021/01/11 21:34 編集

確かに7行目に「currentを指定」と書かれておりました、、 ls -lコマンドを打った結果は以下となりました。 中部に「current」があり色もこれだけ異なっていますので、これに原因がありそうでしょうか?? [ec2-user@ip-172-31-38-172 match-you]$ ls -l 合計 416 -rw-rw-r-- 1 ec2-user ec2-user 275 1月 10 03:24 Capfile -rw-rw-r-- 1 ec2-user ec2-user 2289 1月 10 03:24 Gemfile -rw-rw-r-- 1 ec2-user ec2-user 7773 1月 10 03:24 Gemfile.lock -rw-rw-r-- 1 ec2-user ec2-user 709 1月 8 10:12 README.md -rw-rw-r-- 1 ec2-user ec2-user 227 1月 6 10:34 Rakefile drwxrwxr-x 11 ec2-user ec2-user 142 1月 6 10:34 app -rw-rw-r-- 1 ec2-user ec2-user 1722 1月 6 10:34 babel.config.js drwxrwxr-x 2 ec2-user ec2-user 125 1月 6 10:34 bin drwxrwxr-x 7 ec2-user ec2-user 4096 1月 11 03:42 config -rw-rw-r-- 1 ec2-user ec2-user 130 1月 6 10:34 config.ru lrwxrwxrwx 1 ec2-user ec2-user 42 1月 8 13:44 current -> /var/www/match-you/releases/20210108134217 drwxrwxr-x 3 ec2-user ec2-user 54 1月 10 03:24 db drwxrwxr-x 4 ec2-user ec2-user 33 1月 6 10:34 lib drwxrwxr-x 2 ec2-user ec2-user 116 1月 8 10:34 log drwxrwxr-x 647 ec2-user ec2-user 24576 1月 8 10:52 node_modules -rw-rw-r-- 1 ec2-user ec2-user 336 1月 6 10:34 package.json -rw-rw-r-- 1 ec2-user ec2-user 224 1月 6 10:34 postcss.config.js drwxrwxr-x 4 ec2-user ec2-user 186 1月 6 13:12 public drwxrwxr-x 3 ec2-user ec2-user 28 1月 8 13:44 releases drwxrwxr-x 7 ec2-user ec2-user 156 1月 8 13:42 repo -rw-rw-r-- 1 ec2-user ec2-user 114 1月 8 13:44 revisions.log drwxrwxr-x 7 ec2-user ec2-user 70 1月 8 13:42 shared drwxrwxr-x 2 ec2-user ec2-user 19 1月 6 10:34 storage drwxrwxr-x 10 ec2-user ec2-user 195 1月 6 10:34 test drwxrwxr-x 6 ec2-user ec2-user 105 1月 8 10:35 tmp drwxrwxr-x 2 ec2-user ec2-user 19 1月 6 10:34 vendor -rw-rw-r-- 1 ec2-user ec2-user 332067 1月 6 10:34 yarn.lock [ec2-user@ip-172-31-38-172 match-you]$ 以下の通り、configの前にcurrentパスを入れてunicorn_railsを実行してみたのですが、上手くいきませんでした。。 [ec2-user@ip-172-31-38-172 match-you]$ bundle exec unicorn_rails -c /var/www/match-you/current/config/unicorn.rb -D -E production master failed to start, check stderr log for details
yu_1985

2021/01/12 03:09

> /var/www/match-you/current/config/unicorn.rb こちらが正しいパスかは確認されましたか? また、表示される内容が変わってるように見えるので改めてunicorn.stderr.logを確認してみてください。(途中のメッセージを消したりはしてませんよね?)
shimataroo

2021/01/12 03:49 編集

正しいパスかの確認の仕方が分かっておらず申し訳ございません。match-youの直下にconfigフォルダがあるため「current」をパスに含める意義をいまいち理解できておりません。。 lessコマンドを実行した結果は下記となりました。途中のメッセージは消していないのですが、一番下の最新の日付が4日前の「2021年1月8日」となっており違和感を覚えているのですが、そもそも正しくメッセージが表示されていないということでしょうか?? 度々お手数お掛けしてしまい、大変申し訳ございません。 /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:205:in `pid=': Already running on PID:11935 (or pid=/var/www/match-you/tmp/pids/unicorn.pid is stale) (ArgumentError) from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:137:in `start' from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `<top (required)>' from /home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails:23:in `load' from /home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails:23:in `<main>' I, [2021-01-08T11:25:46.370087 #11935] INFO -- : reaped #<Process::Status: pid 11943 exit 0> worker=0 I, [2021-01-08T11:25:46.370223 #11935] INFO -- : master complete I, [2021-01-08T11:27:15.438576 #12119] INFO -- : Refreshing Gem list I, [2021-01-08T11:27:16.769719 #12119] INFO -- : listening on addr=0.0.0.0:3000 fd=9 I, [2021-01-08T11:27:16.774532 #12119] INFO -- : master process ready I, [2021-01-08T11:27:16.778082 #12127] INFO -- : worker=0 ready I, [2021-01-08T12:18:19.503694 #12119] INFO -- : reaped #<Process::Status: pid 12127 exit 0> worker=0 I, [2021-01-08T12:18:19.504358 #12119] INFO -- : master complete I, [2021-01-08T12:18:52.167629 #12614] INFO -- : Refreshing Gem list I, [2021-01-08T12:18:53.952263 #12614] INFO -- : listening on addr=/var/www/match-you/tmp/sockets/unicorn.sock fd=9 I, [2021-01-08T12:18:53.960691 #12614] INFO -- : master process ready I, [2021-01-08T12:18:53.964333 #12622] INFO -- : worker=0 ready I, [2021-01-08T13:39:20.944559 #12614] INFO -- : reaped #<Process::Status: pid 12622 exit 0> worker=0 I, [2021-01-08T13:39:20.944684 #12614] INFO -- : master complete (END)
yu_1985

2021/01/12 03:59

lsコマンドで該当ディレクトリにファイルが存在するかを確認するだけです。 ls -l /var/www/rails/match-you/current ls -l /var/www/rails/match-you/current/config > 「current」をパスに含める意義をいまいち理解できておりません それは自分でworking directoryをcurrentとするようconfigに設定しているからなのですが…。 それにも関わらずプロジェクトディレクトリの配下に様々なディレクトリが存在しているので、どのようにデプロイを行ったのかが非常に気になります。 ひねくれたことをしていなければcapistranoのデフォルトに従ってデプロイしていると思いますのでcurrentで参照しているディレクトリに最新のソースがあるはずです。 それぞれのディレクトリが何を指しているかは例えばこちらの記事とかをご参照ください。 https://qiita.com/kneegorilla/items/c66fb624002c3db370c3#currentshared%E3%81%A8%E3%81%AF
yu_1985

2021/01/12 04:02

あとconfig/deploy.rbの内容も貼ったほうがいいと思います。
shimataroo

2021/01/12 09:38

「ls -l /var/www/rails/match-you/current」を実行した時の結果は以下の通りでした。 「コマンドが見つかりません」といくつか出てくるのですが、こちらも何かの不具合でしょうか?? ``` [ec2-user@ip-172-31-38-172 match-you]$ # capistranoのバージョンを記載。固定のバージョンを利用し続け、バージョン変更によるトラブルを防止する [ec2-user@ip-172-31-38-172 match-you]$ lock '3.15.0' -bash: lock: コマンドが見つかりません [ec2-user@ip-172-31-38-172 match-you]$ [ec2-user@ip-172-31-38-172 match-you]$ # Capistranoのログの表示に利用する [ec2-user@ip-172-31-38-172 match-you]$ set :application, 'match-you' [ec2-user@ip-172-31-38-172 match-you]$ [ec2-user@ip-172-31-38-172 match-you]$ # どのリポジトリからアプリをpullするかを指定する [ec2-user@ip-172-31-38-172 match-you]$ set :repo_url, 'git@github.com:yutaro-kugishima/match-you.git' [ec2-user@ip-172-31-38-172 match-you]$ [ec2-user@ip-172-31-38-172 match-you]$ # バージョンが変わっても共通で参照するディレクトリを指定 [ec2-user@ip-172-31-38-172 match-you]$ set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system', 'public/uploads') -bash: 予期しないトークン `(' 周辺に構文エラーがあります [ec2-user@ip-172-31-38-172 match-you]$ [ec2-user@ip-172-31-38-172 match-you]$ set :rbenv_type, :user [ec2-user@ip-172-31-38-172 match-you]$ set :rbenv_ruby, '2.6.5' #カリキュラム通りに進めた場合、’2.6.5’ です [ec2-user@ip-172-31-38-172 match-you]$ [ec2-user@ip-172-31-38-172 match-you]$ # どの公開鍵を利用してデプロイするか [ec2-user@ip-172-31-38-172 match-you]$ set :ssh_options, auth_methods: ['publickey'], [ec2-user@ip-172-31-38-172 match-you]$ keys: ['~/.ssh/sample.pem'] -bash: keys:: コマンドが見つかりません [ec2-user@ip-172-31-38-172 match-you]$ [ec2-user@ip-172-31-38-172 match-you]$ # プロセス番号を記載したファイルの場所 [ec2-user@ip-172-31-38-172 match-you]$ set :unicorn_pid, -> { "#{shared_path}/tmp/pids/unicorn.pid" } [ec2-user@ip-172-31-38-172 match-you]$ [ec2-user@ip-172-31-38-172 match-you]$ # Unicornの設定ファイルの場所 [ec2-user@ip-172-31-38-172 match-you]$ set :unicorn_config_path, -> { "#{current_path}/config/unicorn.rb" } [ec2-user@ip-172-31-38-172 match-you]$ set :keep_releases, 5 [ec2-user@ip-172-31-38-172 match-you]$ [ec2-user@ip-172-31-38-172 match-you]$ # デプロイ処理が終わった後、Unicornを再起動するための記述 [ec2-user@ip-172-31-38-172 match-you]$ after 'deploy:publishing', 'deploy:restart' -bash: after: コマンドが見つかりません [ec2-user@ip-172-31-38-172 match-you]$ namespace :deploy do -bash: namespace: コマンドが見つかりません [ec2-user@ip-172-31-38-172 match-you]$ task :restart do -bash: task: コマンドが見つかりません [ec2-user@ip-172-31-38-172 match-you]$ invoke 'unicorn:restart' -bash: invoke: コマンドが見つかりません [ec2-user@ip-172-31-38-172 match-you]$ end -bash: end: コマンドが見つかりません [ec2-user@ip-172-31-38-172 match-you]$ end ``` また、ls -l /var/www/rails/match-you/current/configを実行したときは以下の通り、 ファイルが存在しておりませんでした。 ``` [ec2-user@ip-172-31-38-172 match-you]$ ls -l /var/www/rails/match-you/current/config ls: /var/www/rails/match-you/current/config にアクセスできません: No such file or directory [ec2-user@ip-172-31-38-172 match-you]$ ``` capistranoについては、今回初めて使用しましたのでデフォルトに従って行いました。 また、Qiitaの記事をお送り頂きありがとうございます。 config/deploy.rbの内容は質問の方に貼らせて頂きました。
yu_1985

2021/01/12 10:16

> コマンドが見つかりません」といくつか出てくるのですが、 間違ってconfigの内容を貼り付けてるからですね…。 > ls: /var/www/rails/match-you/current/config にアクセスできません: No such file or directory よくよく見たら > cd /var/www/match-you なので、そもそもrailsなんてディレクトリが存在しないのが原因っぽいですね。 それを回答に書きます
guest

回答2

0

ベストアンサー

bash

1bundle exec unicorn_rails -c /var/www/rails/match-you/config/unicorn.conf.rb -D -E production

で、/var/www/rails/match-you/というディレクトリを指定していますが、

EC2で本アプリにディレクトリを移動する際に、以下のようになコマンドを使用していたためです。。

[ec2-user@ip-172-31-38-172 ~]$ cd /var/www/match-you

ということは、そもそもconfigで指定するパスが間違っているのではないでしょうか。

Capistranoを使ってデプロイして、リリースごとに参照ソースを切り替えるようにしているにも関わらずプロジェクトディレクトリの配下にcurrnetの下にあるべきものが沢山配置されているのがちょっと謎ですが。
/var/www/rails/match-you//var/www/match-you/に修正すれば一旦今回の問題は解消されると思われます。

恐らく本来は

bash

1bundle exec unicorn_rails -c /var/www/match-you/current/config/unicorn.rb -D -E production

だったのはないでしょうか。(configディレクトリ配下の実際のファイル名がわからないので、書いていただいたunicorn.rbとして書いています)

投稿2021/01/12 10:24

yu_1985

総合スコア7447

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

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

shimataroo

2021/01/12 11:23

回答頂きありがとうございます。コマンドを上記の通り修正して実行してみたのですが、再び同じエラーとなってしまいました。。パスの記載以外に問題があると考えた方が良いでしょうか? ``` [ec2-user@ip-172-31-38-172 match-you]$ bundle exec unicorn_rails -c /var/www/match-you/current/config/unicorn.rb -D -E production master failed to start, check stderr log for details ``` lessコマンドで詳細を確認すると以下となります。 ``` /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:205:in `pid=': Already running on PID:11935 (or pid=/var/www/match-you/tmp/pids/unicorn.pid is stale) (ArgumentError) from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:137:in `start' from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `<top (required)>' from /home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails:23:in `load' from /home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails:23:in `<main>' I, [2021-01-08T11:25:46.370087 #11935] INFO -- : reaped #<Process::Status: pid 11943 exit 0> worker=0 I, [2021-01-08T11:25:46.370223 #11935] INFO -- : master complete I, [2021-01-08T11:27:15.438576 #12119] INFO -- : Refreshing Gem list I, [2021-01-08T11:27:16.769719 #12119] INFO -- : listening on addr=0.0.0.0:3000 fd=9 I, [2021-01-08T11:27:16.774532 #12119] INFO -- : master process ready I, [2021-01-08T11:27:16.778082 #12127] INFO -- : worker=0 ready I, [2021-01-08T12:18:19.503694 #12119] INFO -- : reaped #<Process::Status: pid 12127 exit 0> worker=0 I, [2021-01-08T12:18:19.504358 #12119] INFO -- : master complete I, [2021-01-08T12:18:52.167629 #12614] INFO -- : Refreshing Gem list I, [2021-01-08T12:18:53.952263 #12614] INFO -- : listening on addr=/var/www/match-you/tmp/sockets/unicorn.sock fd=9 I, [2021-01-08T12:18:53.960691 #12614] INFO -- : master process ready I, [2021-01-08T12:18:53.964333 #12622] INFO -- : worker=0 ready I, [2021-01-08T13:39:20.944559 #12614] INFO -- : reaped #<Process::Status: pid 12622 exit 0> worker=0 I, [2021-01-08T13:39:20.944684 #12614] INFO -- : master complete (END) ``` また、コメントの方に記載頂いた「間違ってconfigの内容を貼り付けている」の内容が理解できておらず申し訳ございません。。deploy.rb以外の内容を貼り付けるのが正しいということでしょうか?? > コマンドが見つかりません」といくつか出てくるのですが、 間違ってconfigの内容を貼り付けてるからですね…。
yu_1985

2021/01/12 11:50

プロジェクトディレクトリ直下の構成を確認してもらった時に、currentディレクトリが存在するにも関わらずプロジェクトディレクトリ直下にも多数ディレクトリがあるのが気になると書きましたが、そもそも参照すべきログのパスが間違っているような気がしますね。 見ているログファイルのパスはどうなってますか? unicorn.rbの内容から考えるとshared/logの配下だと思われますが、もしかしてプロジェクトディレクトリ直下のlogディレクトリを見てませんか? > 「間違ってconfigの内容を貼り付けている」 ターミナルに変なものコピペで貼り付けちゃったせいでエラーでちゃってますよってだけです。 シェルコマンドじゃないのでそんなコマンドないですと言われるのが当然です。 単なるミスなのでそこは無視してください。
shimataroo

2021/01/12 23:06

>見ているログファイルのパスはどうなってますか? >unicorn.rbの内容から考えるとshared/logの配下だと思われますが、もしかしてプロジェクトディレクトリ直下のlogディレクトリを見てませんか? ご指摘の通り、今までlessコマンドでは以下を実行しておりました、、 申し訳ございません。 [ec2-user@ip-172-31-38-172 match-you]$ less log/production.log 以下を実行致しました。 ``` [ec2-user@ip-172-31-38-172 match-you]$ less shared/log/production.log I, [2021-01-10T01:11:55.013887 #25698] INFO -- : [1e9f12b4-d7cb-4428-b220-2840f493d54b] Started GET "/index.php" for 14.155.221.228 at 2021-01-10 01:11:55 +0000 F, [2021-01-10T01:11:55.014442 #25698] FATAL -- : [1e9f12b4-d7cb-4428-b220-2840f493d54b] [1e9f12b4-d7cb-4428-b220-2840f493d54b] ActionController::RoutingError (No route matches [GET] "/index.php"): [1e9f12b4-d7cb-4428-b220-2840f493d54b] [1e9f12b4-d7cb-4428-b220-2840f493d54b] actionpack (6.0.3.4) lib/action_dispatch/middleware/debug_exceptions.rb:36:in `call' [1e9f12b4-d7cb-4428-b220-2840f493d54b] actionpack (6.0.3.4) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call' [1e9f12b4-d7cb-4428-b220-2840f493d54b] railties (6.0.3.4) lib/rails/rack/logger.rb:37:in `call_app' [1e9f12b4-d7cb-4428-b220-2840f493d54b] railties (6.0.3.4) lib/rails/rack/logger.rb:26:in `block in call' [1e9f12b4-d7cb-4428-b220-2840f493d54b] activesupport (6.0.3.4) lib/active_support/tagged_logging.rb:80:in `block in tagged' [1e9f12b4-d7cb-4428-b220-2840f493d54b] activesupport (6.0.3.4) lib/active_support/tagged_logging.rb:28:in `tagged' [1e9f12b4-d7cb-4428-b220-2840f493d54b] activesupport (6.0.3.4) lib/active_support/tagged_logging.rb:80:in `tagged' [1e9f12b4-d7cb-4428-b220-2840f493d54b] railties (6.0.3.4) lib/rails/rack/logger.rb:26:in `call' [1e9f12b4-d7cb-4428-b220-2840f493d54b] actionpack (6.0.3.4) lib/action_dispatch/middleware/remote_ip.rb:81:in `call' [1e9f12b4-d7cb-4428-b220-2840f493d54b] actionpack (6.0.3.4) lib/action_dispatch/middleware/request_id.rb:27:in `call' [1e9f12b4-d7cb-4428-b220-2840f493d54b] rack (2.2.3) lib/rack/method_override.rb:24:in `call' [1e9f12b4-d7cb-4428-b220-2840f493d54b] rack (2.2.3) lib/rack/runtime.rb:22:in `call' [1e9f12b4-d7cb-4428-b220-2840f493d54b] activesupport (6.0.3.4) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call' [1e9f12b4-d7cb-4428-b220-2840f493d54b] actionpack (6.0.3.4) lib/action_dispatch/middleware/executor.rb:14:in `call' [1e9f12b4-d7cb-4428-b220-2840f493d54b] rack (2.2.3) lib/rack/sendfile.rb:110:in `call' [1e9f12b4-d7cb-4428-b220-2840f493d54b] actionpack (6.0.3.4) lib/action_dispatch/middleware/host_authorization.rb:76:in `call' [1e9f12b4-d7cb-4428-b220-2840f493d54b] railties (6.0.3.4) lib/rails/engine.rb:527:in `call' [1e9f12b4-d7cb-4428-b220-2840f493d54b] rack (2.2.3) lib/rack/tempfile_reaper.rb:15:in `call' [1e9f12b4-d7cb-4428-b220-2840f493d54b] rack (2.2.3) lib/rack/common_logger.rb:38:in `call' [1e9f12b4-d7cb-4428-b220-2840f493d54b] rack (2.2.3) lib/rack/chunked.rb:98:in `call' [1e9f12b4-d7cb-4428-b220-2840f493d54b] rack (2.2.3) lib/rack/content_length.rb:17:in `call' [1e9f12b4-d7cb-4428-b220-2840f493d54b] unicorn (5.4.1) lib/unicorn/http_server.rb:606:in `process_client' [1e9f12b4-d7cb-4428-b220-2840f493d54b] unicorn (5.4.1) lib/unicorn/http_server.rb:701:in `worker_loop' [1e9f12b4-d7cb-4428-b220-2840f493d54b] unicorn (5.4.1) lib/unicorn/http_server.rb:549:in `spawn_missing_workers' [1e9f12b4-d7cb-4428-b220-2840f493d54b] unicorn (5.4.1) lib/unicorn/http_server.rb:142:in `start' [1e9f12b4-d7cb-4428-b220-2840f493d54b] unicorn (5.4.1) bin/unicorn:126:in `<top (required)>' [1e9f12b4-d7cb-4428-b220-2840f493d54b] /var/www/match-you/shared/bundle/ruby/2.6.0/bin/unicorn:23:in `load' [1e9f12b4-d7cb-4428-b220-2840f493d54b] /var/www/match-you/shared/bundle/ruby/2.6.0/bin/unicorn:23:in `<main>' I, [2021-01-10T01:11:55.147061 #25698] INFO -- : [1b2c5c60-bd63-45aa-bc2a-0faaf1cc3e2b] Started GET "/" for 14.155.221.228 at 2021-01-10 01:11:55 +0000 I, [2021-01-10T01:11:55.147681 #25698] INFO -- : [1b2c5c60-bd63-45aa-bc2a-0faaf1cc3e2b] Processing by UsersController#index as HTML I, [2021-01-10T01:11:55.148060 #25698] INFO -- : [1b2c5c60-bd63-45aa-bc2a-0faaf1cc3e2b] Filter chain halted as :basic_auth rendered or redirected I, [2021-01-10T01:11:55.148165 #25698] INFO -- : [1b2c5c60-bd63-45aa-bc2a-0faaf1cc3e2b] Completed 401 Unauthorized in 0ms (Allocations: 153) (END) ``` 「ActionController::RoutingError (No route matches [GET] "/index.php"):」 WordPressのテンプレートファイルを使用していないのでかなり違和感があるのですが、改めて確認してみても、ローカル環境ではアプリが問題なく動作できている状態です。アプリの実装自体に問題があるということでしょうか??
yu_1985

2021/01/13 02:13

なぜ見るログをunicorn.stderr.logではなくproduction.logに変えたんでしょうか。 > master failed to start, check stderr log for details と出ているはずですが…。 そして、それはunicornを立ち上げようとした時間帯のログでしょうか? 恐らくそのログに出ているのは外部からそういうアクセスがあったけど、そんなパスは実装してないのでエラーになってる、というだけです。 インターネットにWEBサーバを公開しているとそういったアクセスはよくあります。 存在しないパスへのアクセスがあった際の処理をもう少し何とかしたほうがいいかもしれませんが、今回の問題とは別なので一旦置いときます。
shimataroo

2021/01/13 08:52

以前実行したコマンドを深く考えずに使用してしまっておりました。。 申し訳ございません。unicorn.stderr.logで実行致しました。 [ec2-user@ip-172-31-38-172 match-you]$ less shared/log/unicorn.stderr.log ``` I, [2021-01-12T11:07:48.486524 #17917] INFO -- : Refreshing Gem list I, [2021-01-12T11:07:49.594301 #17917] INFO -- : unlinking existing socket=/var/www/match-you/shared/tmp/sockets/unicorn.sock I, [2021-01-12T11:07:49.594495 #17917] INFO -- : listening on addr=/var/www/match-you/shared/tmp/sockets/unicorn.sock fd=9 E, [2021-01-12T11:07:49.594882 #17917] ERROR -- : Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) (Mysql2::Error::ConnectionError) /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:90:in `connect' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:90:in `initialize' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/mysql2_adapter.rb:24:in `new' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/mysql2_adapter.rb:24:in `mysql2_connection' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:887:in `new_connection' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in `checkout_new_connection' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:910:in `try_to_checkout_new_connection' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:871:in `acquire_connection' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:593:in `checkout' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:437:in `connection' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:1119:in `retrieve_connection' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.4/lib/active_record/connection_handling.rb:221:in `retrieve_connection' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.4/lib/active_record/connection_handling.rb:189:in `connection' /var/www/match-you/current/config/unicorn.rb:36:in `block in reload' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:543:in `spawn_missing_workers' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:142:in `start' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `<top (required)>' /home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails:23:in `load' /home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails:23:in `<top (required)>' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>' /home/ec2-user/.rbenv/versions/2.6.5/bin/bundle:23:in `load' /home/ec2-user/.rbenv/versions/2.6.5/bin/bundle:23:in `<main>' (END) ``` 「Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) (Mysql2::Error::ConnectionError)」とのことでしたので、socketsのパスが誤っているのではと思い確認してみたのですが、以下の通りdatabase.ymlに記載のパスと一致しておりました。 ``` [ec2-user@ip-172-31-38-172 match-you]$ mysql_config --socket /var/lib/mysql/mysql.sock ``` ```database.yml production: <<: *default database: match_you_production username: root password: <%= ENV['DATABASE_PASSWORD'] %> socket: /var/lib/mysql/mysql.sock ``` ググってみますと、mysqldがそもそも起動できていない可能性があるようでしたので、以下で確認してみたのですが、問題なく起動できているようです。 ``` [ec2-user@ip-172-31-38-172 match-you]$ ps aux | grep mysqld ec2-user 30018 0.0 0.0 119436 864 pts/0 S+ 08:23 0:00 grep --color=auto mysqld ``` socketsファイルはmatch-you/tmp直下に入っているのですが、この保管場所を変更した方が良いでしょうか??(外部からのアクセスについてもコメント頂きありがとうございます。今回の問題とは関係ないとのことで安心致しました。)
yu_1985

2021/01/13 09:04

> 問題なく起動できているようです。 本当にその通りの結果ならできてないですね…。 mysqldのプロセスが引っかかってないですよね? その出力結果は自分が打ったgrepコマンドのプロセスです。 なのでmysqldを起動してください。
yu_1985

2021/01/13 09:08

psコマンドの結果をgrepするとgrep自身のプロセスが表示されてしまうのがわかっていれば特に対処しなくてもいいですが、 表示されるのが気持ち悪ければgrepコマンドのプロセスを出力結果から削りましょう。 コマンドの後ろに更に` | grep -v grep`を追加すれば、 grepした結果に対して更にgrepが含まれない行のみを出力できます。
shimataroo

2021/01/13 09:54 編集

自分が打ったgrepのコマンドのプロセスということを失念しており失礼致しました。 以下の通り起動したのですが、再び同様のエラーが出てしまいました。 [ec2-user@ip-172-31-38-172 match-you]$ sudo systemctl start mariadb [ec2-user@ip-172-31-38-172 match-you]$ bundle exec unicorn_rails -c /var/www/match-you/config/unicorn.rb -D -E production bundler: failed to load command: unicorn_rails (/home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails) Errno::ENOENT: No such file or directory @ dir_s_chdir - /var/www/current /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:596:in `chdir' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:596:in `working_directory' /var/www/match-you/config/unicorn.rb:8:in `reload' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:84:in `instance_eval' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:84:in `reload' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:77:in `initialize' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:77:in `new' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:77:in `initialize' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `new' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `<top (required)>' /home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails:23:in `load' /home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails:23:in `<top (required)>' master failed to start, check stderr log for details mysqldを起動しようとすると、以下のエラーが出てしまいました。 log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock [ec2-user@ip-172-31-38-172 match-you]$ sudo systemctl start mariadb [ec2-user@ip-172-31-38-172 match-you]$ ps aux | grep mysqld mysql 31016 0.0 0.2 119984 2900 ? Ss 09:27 0:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr mysql 31182 0.0 8.4 1015916 85192 ? Sl 09:27 0:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock ec2-user 31550 0.0 0.0 119436 912 pts/4 S+ 09:36 0:00 grep --color=auto mysqld [ec2-user@ip-172-31-38-172 match-you]$ tmp/pidファイルが悪さをしているのではと思い、削除後に再度同様のコマンドを実行したのですが、結果は同じでした、、 1つ気になるのが、lessコマンドで詳細ログを確認した際の、以下エラー文なのですが、「1月12日11時7分49秒?」は私がunicorn_railsを実行した時間ではありません。。そもそもunicorn_railsがきちんと実行できていないため、過去の日時が表示されているということでしょうか?? E, [2021-01-12T11:07:49.594882 #17917] ERROR -- : Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) (Mysql2::Error::ConnectionError)
yu_1985

2021/01/13 09:53

参照すべきconfigは /var/www/match-you/config/unicorn.rb でよいのでしょうか? /var/www/match-you/current/config/unicorn.rb では? 正直、ディレクトリ構成がごちゃごちゃしすぎてるので、一旦消してcapistranoで再度上げ直したほうがいいと思います。 ログは積み重なっていくものなので、過去のものはいずれにしても表示されます。 直近で実行した際のログが見つからないというのであれば、直近の実行では何も出てなかったというだけです。
shimataroo

2021/01/13 12:16

パスにcurrentが抜けており失礼致しました。 /var/www/match-you/current/config/unicorn.rbを再度実行したのですが、同様のエラーとなりました。。 >正直、ディレクトリ構成がごちゃごちゃしすぎてるので、一旦消してcapistranoで再度上げ直したほうがいいと思います。 承知致しました。。。「一旦消して」の意味が理解できておらず申し訳ないのですが、「unicorn.rb」「deploy.rb」「database.yml」などの関連ファイルをまとめて削除して全て1から作り直すということでしょうか?????? >ログは積み重なっていくものなので、過去のものはいずれにしても表示されます。 >直近で実行した際のログが見つからないというのであれば、直近の実行では何も出てなかったというだけです。 承知致しました。実行して何も出てこない場合もあるのですね。ありがとうございます。
yu_1985

2021/01/13 15:54

> /var/www/match-you/current/config/unicorn.rbを再度実行 いや、それは実行ファイルじゃなくてconfigファイルのパスですが…。 -c オプションに指定するパスが違うのではないですか?という話です。 そして「同様のエラー」で片付けずにちゃんと実行結果を貼ってください。 > 「一旦消して」の意味が理解できておらず プロジェクトのディレクトリごと全削除してデプロイし直したほうが早いのでは、という話です。 現に複数のパスに同じファイルがあることで混乱してますよね。 > 実行して何も出てこない場合もある 何も出てこない場合は「何も出てこないこと」が情報になります。 何も出てこないということはそもそもそこまで到達してないか、エラーではないかのどちらかですね。
shimataroo

2021/01/13 23:47

言葉足らずで失礼致しました。昨夜はcurrentをパスに含めて、以下で実行しておりました。 bundle exec unicorn_rails -c /var/www/match-you/current/config/unicorn.rb -D -E production 同様のエラーについて、実行結果を晴れておらず大変申し訳ございません。以下となります。 bundler: failed to load command: unicorn_rails (/home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails) Errno::ENOENT: No such file or directory @ rb_sysopen - /var/www/match-you/current/config/unicorn.rb /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:84:in `read' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:84:in `reload' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:77:in `initialize' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:77:in `new' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:77:in `initialize' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `new' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `<top (required)>' /home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails:23:in `load' /home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails:23:in `<top (required)>' master failed to start, check stderr log for details lessコマンドで詳細確認したのですが、昨日unicornを実行した時間帯のログは確認できませんでした。 (日付は1月8日が最新) [ec2-user@ip-172-31-38-172 match-you]$ less log/unicorn.stderr.log home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:205:in `pid=': Already running on PID:11935 (or pid=/var/www/match-you/tmp/pids/unicorn.pid is stale) (ArgumentError) from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:137:in `start' from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `<top (required)>' from /home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails:23:in `load' from /home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails:23:in `<main>' I, [2021-01-08T11:25:46.370087 #11935] INFO -- : reaped #<Process::Status: pid 11943 exit 0> worker=0 I, [2021-01-08T11:25:46.370223 #11935] INFO -- : master complete I, [2021-01-08T11:27:15.438576 #12119] INFO -- : Refreshing Gem list I, [2021-01-08T11:27:16.769719 #12119] INFO -- : listening on addr=0.0.0.0:3000 fd=9 I, [2021-01-08T11:27:16.774532 #12119] INFO -- : master process ready I, [2021-01-08T11:27:16.778082 #12127] INFO -- : worker=0 ready I, [2021-01-08T12:18:19.503694 #12119] INFO -- : reaped #<Process::Status: pid 12127 exit 0> worker=0 I, [2021-01-08T12:18:19.504358 #12119] INFO -- : master complete I, [2021-01-08T12:18:52.167629 #12614] INFO -- : Refreshing Gem list I, [2021-01-08T12:18:53.952263 #12614] INFO -- : listening on addr=/var/www/match-you/tmp/sockets/unicorn.sock fd=9 I, [2021-01-08T12:18:53.960691 #12614] INFO -- : master process ready I, [2021-01-08T12:18:53.964333 #12622] INFO -- : worker=0 ready I, [2021-01-08T13:39:20.944559 #12614] INFO -- : reaped #<Process::Status: pid 12622 exit 0> worker=0 I, [2021-01-08T13:39:20.944684 #12614] INFO -- : master complete (END) >プロジェクトのディレクトリごと全削除してデプロイし直したほうが早いのでは、という話です。 現に複数のパスに同じファイルがあることで混乱してますよね。 ご指摘の通り、かなり混乱しております。ディレクトリ毎削除(本アプリVScodeの記述を全消去?)について、具体的なイメージが持てておらず申し訳ございません。ターミナルで何かコマンドを実行するということでしょうか?ググってみたのですが、それらしい回答が得られませんでした、、 >何も出てこない場合は「何も出てこないこと」が情報になります。 >何も出てこないということはそもそもそこまで到達してないか、エラーではないかのどちらかですね。 承知致しました。自動デプロイとドメイン取得まで進めていましたので、てっきりuniconr_railsの部分のみの問題かと思っておりました、、
yu_1985

2021/01/14 01:09

> less log/unicorn.stderr.log 参照するログのパスが違うという指摘は既に行っています…。 こういうことが頻繁に起こるので、余計なファイル・ディレクトリが入っている現状の構成を改善すべきという話です。 > ターミナルで何かコマンドを実行するということでしょうか? そういうことです。 sudo rm -rf /var/www/match-you でプロジェクトディレクトリごと全部消えます。capistranoで上げ直してください。 どのように調べたかわかりませんが「ディレクトリ 削除」だけでもすぐ出てきます。 ここでパスを間違えると消すべきではないものが消えてしまうので慎重に行ってください。 これに限らず何かを削除する際は対象を誤らないように慎重に行う必要があります。
shimataroo

2021/01/14 03:55

>参照するログのパスが違うという指摘は既に行っています…。 >こういうことが頻繁に起こるので、余計なファイル・ディレクトリが入っている現状の構成を改善すべきという話です。 承知致しました。アドバイスの通りに対応させて頂きたいと思います。 >sudo rm -rf /var/www/match-you >でプロジェクトディレクトリごと全部消えます。capistranoで上げ直してください。 >どのように調べたかわかりませんが「ディレクトリ 削除」だけでもすぐ出てきます。 >ここでパスを間違えると消すべきではないものが消えてしまうので慎重に行ってください。 調べ方が甘く申し訳ございません。コマンドをご教示頂きありがとうございます。 「プロジェクトディレクトリごと全部消えます」(ファイルの内容の復元不可能?)について初めて実行するということもあり、正直かなりの不安を抱いているのですが、capistranoでコマンド実行することで元通り復元されるということなのでしょうか?? (下手をすると、アプリをまた1から作り直さないといけないことになり得る?ことが一番の不安です) 根本的なことが理解できておらず大変申し訳ございませんが、その辺りも少しコメント頂けますと精神的にもかなり助かります。。。
yu_1985

2021/01/14 04:03

> 「プロジェクトディレクトリごと全部消えます」(ファイルの内容の復元不可能?)について初めて実行するということもあり、正直かなりの不安を抱いているのですが、capistranoでコマンド実行することで元通り復元されるということなのでしょうか?? 復元も何も、capistranoを使ってローカルからアップロードするのではないですか?
yu_1985

2021/01/14 04:09

ソースはEC2上にしかないわけではないですよね? もしそうなら今すぐgit管理してください。 最新版のソースはEC2上にあるわけじゃないのと、デプロイの方法が確立されてるのなら再度デプロイするだけなので何も問題ありません。 それで差異が発生するのであれば管理の方法に問題があります。 ログとかは消えちゃいますけど、現在どれが参照すべきファイルかもきちんと把握できてない状態であることを鑑みるとまっさらな状態にして改めてデプロイしたほうがよい、という判断です。
shimataroo

2021/01/14 07:06

>復元も何も、capistranoを使ってローカルからアップロードするのではないですか? おっしゃる通りです。sudo rm -rf /var/www/match-youコマンドを実行することで、ローカルのディレクトリやファイルなども全て削除されてしまうと思っておりました。。。 >ソースはEC2上にしかないわけではないですよね? gitとは常に連携しております。 >最新版のソースはEC2上にあるわけじゃないのと、デプロイの方法が確立されてるのなら再度デプロイするだけなので何も問題ありません。 それで差異が発生するのであれば管理の方法に問題があります。 >ログとかは消えちゃいますけど、現在どれが参照すべきファイルかもきちんと把握できてない状態であることを鑑みるとまっさらな状態にして改めてデプロイしたほうがよい、という判断です。 承知致しました。先ほど以下のコマンドで試しに自動デプロイを試してみたのですが、 sshでエラーが出てしまいました???? 上記のディレクトリ毎の削除は、下記エラーを解消してからの方が良いでしょうか?? 色々質問してしまい申し訳ございません。 $ bundle exec cap production deploy .2.0/lib/capistrano/tasks/rbenv.rake:10:in `block (3 levels) in <top (required)>' 8: from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/sshkit-1.21.1/lib/sshkit/backends/abstract.rb:61:in `test' 7: from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/sshkit-1.21.1/lib/sshkit/backends/abstract.rb:148:in `create_command_and_execute' 6: from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/sshkit-1.21.1/lib/sshkit/backends/abstract.rb:148:in `tap' 5: from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/sshkit-1.21.1/lib/sshkit/backends/abstract.rb:148:in `block in create_command_and_execute' 4: from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/sshkit-1.21.1/lib/sshkit/backends/netssh.rb:130:in `execute_command' 3: from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/sshkit-1.21.1/lib/sshkit/backends/netssh.rb:177:in `with_ssh' 2: from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/sshkit-1.21.1/lib/sshkit/backends/connection_pool.rb:63:in `with' 1: from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/sshkit-1.21.1/lib/sshkit/backends/connection_pool.rb:63:in `call' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/net-ssh-6.1.0/lib/net/ssh.rb:268:in[ec2-user@ip-172-31-38-172 match-you]$ 1: from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/sshkit-1.21.1/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/sshkit-1.21.1/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as ec2-user@13.231.61.142: Authentication failed for user ec2-user@13.231.61.142 (SSHKit::Runner::ExecuteError) (Backtrace restricted to imported tasks)
yu_1985

2021/01/14 07:34

目的は余計なファイルを消すことなので、capistranoのデプロイだけやっても目的が達成できません。 あと、そのエラーはSSHの認証エラーです。 capistranoをEC2サーバ上で実行してますね? それだとうまく行かないでしょう。 capistranoの用途を間違えています。capistranoが何をしているかをもう一度確認し直してください。 capistranoは主にローカルからリモートホストへのデプロイを行うためのアプリケーションで、sshを使ってホストに接続しに行きます。 一応、動作としてEC2インスタンス上で自分自身に対してデプロイをすることもできますが、通常そんなことはしないのでssh keyの設定をEC2上では何もしていないはずです。 おとなしくローカルから実行してください。
shimataroo

2021/01/14 08:21

EC2サーバー上で実行しておりました。申し訳ございません。 以下の通りローカルで実行致しました所、途中までは問題なかったのですが、エラーとなっております。。 このエラー解決より前に、sudo rm -rf /var/www/match-youコマンドを実行した方が良いでしょうか?? kugishimayutaro@kugishirounoAir match-you % bundle exec cap production deploy [Deprecation Notice] Future versions of Capistrano will not load the Git SCM plugin by default. To silence this deprecation warning, add the following to your Capfile after `require "capistrano/deploy"`: require "capistrano/scm/git" install_plugin Capistrano::SCM::Git 00:00 git:wrapper 01 mkdir -p /tmp ✔ 01 ec2-user@13.231.61.142 0.218s Uploading /tmp/git-ssh-e357ba9247d3ab45ee92.sh 100.0% 02 chmod 700 /tmp/git-ssh-e357ba9247d3ab45ee92.sh ✔ 02 ec2-user@13.231.61.142 0.190s ・ ・ ・ Caused by: SSHKit::Command::Failed: bundle exit status: 1 bundle stdout: Nothing written bundle stderr: bundler: failed to load command: unicorn (/var/www/match-you/shared/bundle/ruby/2.6.0/bin/unicorn) Errno::ENOENT: No such file or directory @ dir_s_chdir - /var/www/match-you/current/current /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:596:in `chdir' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:596:in `working_directory' /var/www/match-you/current/config/unicorn.rb:8:in `reload' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:84:in `instance_eval' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:84:in `reload' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:77:in `initialize' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:77:in `new' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:77:in `initialize' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/bin/unicorn:126:in `new' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/bin/unicorn:126:in `<top (required)>' /var/www/match-you/shared/bundle/ruby/2.6.0/bin/unicorn:23:in `load' /var/www/match-you/shared/bundle/ruby/2.6.0/bin/unicorn:23:in `<top (required)>' master failed to start, check stderr log for details Tasks: TOP => unicorn:start (See full trace by running task with --trace) The deploy has failed with an error: Exception while executing as ec2-user@13.231.61.142: bundle exit status: 1 bundle stdout: Nothing written bundle stderr: bundler: failed to load command: unicorn (/var/www/match-you/shared/bundle/ruby/2.6.0/bin/unicorn) Errno::ENOENT: No such file or directory @ dir_s_chdir - /var/www/match-you/current/current /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:596:in `chdir' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:596:in `working_directory' /var/www/match-you/current/config/unicorn.rb:8:in `reload' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:84:in `instance_eval' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:84:in `reload' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:77:in `initialize' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:77:in `new' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:77:in `initialize' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/bin/unicorn:126:in `new' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/bin/unicorn:126:in `<top (required)>' /var/www/match-you/shared/bundle/ruby/2.6.0/bin/unicorn:23:in `load' /var/www/match-you/shared/bundle/ruby/2.6.0/bin/unicorn:23:in `<top (required)>' master failed to start, check stderr log for details ** DEPLOY FAILED ** Refer to log/capistrano.log for details. Here are the last 20 lines: DEBUG [1c5c2c7f] Command: [ -e /var/www/match-you/shared/tmp/pids/unicorn.pid ] && kill -0 `cat /var/www/match-you/shared/tmp/pids/unicorn.pid` DEBUG [1c5c2c7f] bash: 0 行: kill: (17917) - No such process DEBUG [1c5c2c7f] Finished in 0.202 seconds with exit status 1 (failed). INFO [2b168fc4] Running $HOME/.rbenv/bin/rbenv exec bundle exec unicorn -c /var/www/match-you/current/config/unicorn.rb -E deployment -D as ec2-user@13.231.61.142 DEBUG [2b168fc4] Command: cd /var/www/match-you/current && ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.6.5" RAILS_ENV="production" ; $HOME/.rbenv/bin/rbenv exec bundle exec unicorn -c /var/www/match-you/current/config/unicorn.rb -E deployment -D ) DEBUG [2b168fc4] bundler: failed to load command: unicorn (/var/www/match-you/shared/bundle/ruby/2.6.0/bin/unicorn) DEBUG [2b168fc4] Errno::ENOENT: No such file or directory @ dir_s_chdir - /var/www/match-you/current/current /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:596:in `chdir' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:596:in `working_directory' /var/www/match-you/current/config/unicorn.rb:8:in `reload' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:84:in `instance_eval' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:84:in `reload' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:77:in `initialize' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:77:in `new' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:77:in `initialize' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/bin/unicorn:126:in `new' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/bin/unicorn:126:in `<top (required)>' /var/www/match-you/shared/bundle/ruby/2.6.0/bin/unicorn:23:in `load' /var/www/match-you/shared/bundle/ruby/2.6.0/bin/unicorn:23:in `<top (required)>' DEBUG [2b168fc4] master failed to start, check stderr log for details
yu_1985

2021/01/14 08:43

> Errno::ENOENT: No such file or directory @ dir_s_chdir - /var/www/match-you/current/current 変なところを参照しに行ってるように見えますが、ローカル側でなにか設定を変えましたか?
shimataroo

2021/01/14 08:59

パスの変更することでエラー抜けられるかもと思い、unicorn.rbの中身を以下のように変えてしまったのですがこれがマズかったでしょうか?? app_path = File.expand_path('../../../', __FILE__) ↓ app_path = File.expand_path('../../', __FILE__) それと故意ではないのですが、何かの拍子でREADME.mdのファイルが消えてしまっていることに気づきました。。これは手動で作成し直した方が良いでしょうか??
yu_1985

2021/01/14 09:42

根拠があって変更したりだとか、変更して試行を繰り返すとかならわかるのですが、何も言わずに変更して「うまく行きませんでした」だけだと何が原因でうまく行かなかったのか切り分けることが困難になります。 変更をしたのなら変更をしたときちんと伝えてください。 恐らく、相対パスを変更したために階層がズレてしまったのが原因ですのでもとに戻してください。。 もともとうまく行っていたのだから変更する理由はないと思うのですが…。 > 何かの拍子でREADME.mdのファイルが消えてしまっている ローカルのREADMEのことですか? Git管理しているのならリポジトリ上に全部あるので、ファイルの削除をコミットしていないのならブランチの最新バージョンに戻せばよいのではないでしょうか。 コミットしてしまったとしても履歴には残っているので復元できます。 やり方はこの質問の範疇から外れるので割愛します。
shimataroo

2021/01/14 10:14 編集

>根拠があって変更したりだとか、変更して試行を繰り返すとかならわかるのですが、何も言わずに変更して「うまく行きませんでした」だけだと何が原因でうまく行かなかったのか切り分けることが困難になります。 >変更をしたのなら変更をしたときちんと伝えてください。 >恐らく、相対パスを変更したために階層がズレてしまったのが原因ですのでもとに戻してください。。 >もともとうまく行っていたのだから変更する理由はないと思うのですが…。 無断で勝手な対応をしてしまい申し訳ございませんでした。 他の記事を参照して軽い気持ちで試してしまっておりました、、 以後気をつけるように致します。 元に戻してcapistranoを行った所、無事に自動デプロイ完了致しました。ありがとうございました。 >ローカルのREADMEのことですか? >Git管理しているのならリポジトリ上に全部あるので、ファイルの削除をコミットしていないのならブランチの最新バージョンに戻せばよいのではないでしょうか。 >コミットしてしまったとしても履歴には残っているので復元できます。 >やり方はこの質問の範疇から外れるので割愛します。 ローカルのREDMEとなります。承知致しました。 git pull origin masterコマンド実行後も、復元されていませんでしたのでコミットしてしまったようです、、後ほど自分で調べて対処するように致します。 一応確認なのですがこれから実行する、sudo rm -rf /var/www/match-youコマンドは、[ec2-user@ip-172-31-38-172 match-you]で行うという理解で合っていますでしょうか?
yu_1985

2021/01/14 10:47

> git pull origin masterコマンド実行後も、復元されていませんでしたのでコミットしてしまったようです それはローカルのmasterブランチをリモートリポジトリに追従させるだけで、復元するわけではありません。 コミットしたかどうかについては流石に自分で把握していてほしいところですが、忘れたならまずはコミット履歴を確認してください。 まずgitコマンドの基本的な使い方についても調べることをおすすめします。 > sudo rm -rf /var/www/match-youコマンドは、[ec2-user@ip-172-31-38-172 match-you]で行うという理解で合っていますでしょうか? もちろんです。削除したいのはサーバ上にあるソースです。ローカルではそんなところに置いてないと思いますので多分何も起きないと思いますけれど。 当然ですが、削除したらもう一回capistranoでデプロイしてください。
shimataroo

2021/01/14 13:01 編集

>それはローカルのmasterブランチをリモートリポジトリに追従させるだけで、復元するわけではありません。 >コミットしたかどうかについては流石に自分で把握していてほしいところですが、忘れたならまずはコミット履歴を確認してください。 >まずgitコマンドの基本的な使い方についても調べることをおすすめします。 gitについて理解できておらず申し訳ございませんでした。。 承知致しました。自分で調べるように致します。 >削除したいのはサーバ上にあるソースです。 あっ、これでやっとsudo rm -rf /var/www/match-youコマンドの意味がわかりました。ありがとうございます。 >当然ですが、削除したらもう一回capistranoでデプロイしてください。 capistranoでデプロイ後に、bundle exec unicorn_rails -c /var/www/match-you/current/config/unicorn.rb -D -E productionコマンドを実行したのですが、 該当のディレクトリがないという表示でした。currentも入れていたのですが、 他に何か必要なパスが抜けているということでしょうか?? [ec2-user@ip-172-31-38-172 ~]$ cd /var/www/match-you [ec2-user@ip-172-31-38-172 match-you]$ sudo service nginx restart Redirecting to /bin/systemctl restart nginx.service [ec2-user@ip-172-31-38-172 match-you]$ ps -ef | grep unicorn | grep -v grep ec2-user 13463 1 0 09:52 ? 00:00:01 unicorn master -c /var/www/match-you/current/config/unicorn.rb -E deployment -D ec2-user 13502 13463 0 09:52 ? 00:00:00 unicorn worker[0] -c /var/www/match-you/current/config/unicorn.rb -E deployment -D ec2-user 27274 1 0 11:43 ? 00:00:01 unicorn master -c /var/www/match-you/current/config/unicorn.rb -E deployment -D ec2-user 27313 27274 0 11:43 ? 00:00:00 unicorn worker[0] -c /var/www/match-you/current/config/unicorn.rb -E deployment -D [ec2-user@ip-172-31-38-172 match-you]$ kill 13463 [ec2-user@ip-172-31-38-172 match-you]$ kill 27274 [ec2-user@ip-172-31-38-172 match-you]$ ps -ef | grep unicorn | grep -v grep [ec2-user@ip-172-31-38-172 match-you]$ bundle exec unicorn_rails -c /var/www/match-you/current/config/unicorn.rb -D -E production Could not locate Gemfile or .bundle/ directory [ec2-user@ip-172-31-38-172 match-you]$ bundle exec unicorn_rails -c /var/www/match-you/config/unicorn.rb -D -E production Could not locate Gemfile or .bundle/ directory [ec2-user@ip-172-31-38-172 match-you]$
yu_1985

2021/01/14 16:47 編集

毎度のことですが、エラーの内容をちゃんと見てください。せっかく「なぜエラーになっているか」を表示してくれているのに、それを読み取らなかったら対処が進みません。 今回は今までと出ているエラーが違いますよね? 自分がやっている回答は基本的に出ているエラーを読み取ってエラーの原因を推測するか、不足している情報を得るためにコマンドを実行してもらったり、設定ファイルを貼ってもらったりしているだけです。 物によってはエラーメッセージをGoogleの検索窓に打ち込むだけで解決するものもあります。(残念ながら前提条件を書いていない、あまり役に立たない情報もたくさん引っかかったりしますけど) 今回 > Could not locate Gemfile or .bundle/ directory と、出ています。 デプロイされたソースのディレクトリを確認すると、Gemfileは一体どこに配置されているでしょうか。 恐らく、currentディレクトリ配下ではないですか? ということで、多分currentディレクトリの配下でコマンド実行するとうまくいきます。 ただ、EC2上にproductionでunicornを起動したいにもかかわらず、capistranoでのデプロイ時に別の環境として起動されている事自体が問題だと思うので、ここでやるべきはデプロイのやり直しでしょう。
shimataroo

2021/01/14 22:19

夜分遅くに返事を頂きありがとうございます。 >毎度のことですが、エラーの内容をちゃんと見てください。せっかく「なぜエラーになっているか」を表示してくれているのに、それを読み取らなかったら対処が進みません。 >今回は今までと出ているエラーが違いますよね? エラーが異なっていることは認識していたのですが、きちんと読み取っておらず申し訳ございません。 >恐らく、currentディレクトリ配下ではないですか? >ということで、多分currentディレクトリの配下でコマンド実行するとうまくいきます。 gemfileはcurrentディレクトリ(match-you?)直下にございます(match-you/gemfile)。 そもそもなのですが、”currentディレクトリの配下”について、いまいち理解できておらず申し訳ございません。 以下の通り、unicorn_rails実行時のパスを変更(①match-you/unicorn.rb②match-you/current/unicorn.rb)、③<ec2-user@ip-172-31-38-172 match-you>→<ec2-user@ip-172-31-38-172 current>へ移動して実行してみたのですが、エラーの解決には至りませんでした。 (おそらく私の理解不足で誤った対処法を行っているような気がしているのですが。。) [ec2-user@ip-172-31-38-172 match-you]$ bundle exec unicorn_rails -c /var/www/match-you/unicorn.rb -D -E production Could not locate Gemfile or .bundle/ directory [ec2-user@ip-172-31-38-172 match-you]$ bundle exec unicorn_rails -c /var/www/match-you/current/unicorn.rb -D -E production [ec2-user@ip-172-31-38-172 current]$ bundle exec unicorn_rails -c /var/www/match-you/current/unicorn.rb -D -E production bundler: failed to load command: unicorn_rails (/var/www/match-you/shared/bundle/ruby/2.6.0/bin/unicorn_rails) Errno::ENOENT: No such file or directory @ rb_sysopen - /var/www/match-you/current/unicorn.rb /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:84:in `read' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:84:in `reload' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:77:in `initialize' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:77:in `new' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:77:in `initialize' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `new' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `<top (required)>' /var/www/match-you/shared/bundle/ruby/2.6.0/bin/unicorn_rails:23:in `load' /var/www/match-you/shared/bundle/ruby/2.6.0/bin/unicorn_rails:23:in `<top (required)>' master failed to start, check stderr log for details [ec2-user@ip-172-31-38-172 current]$ bundle exec unicorn_rails -c /var/www/match-you/unicorn.rb -D -E production bundler: failed to load command: unicorn_rails (/var/www/match-you/shared/bundle/ruby/2.6.0/bin/unicorn_rails) Errno::ENOENT: No such file or directory @ rb_sysopen - /var/www/match-you/unicorn.rb /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:84:in `read' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:84:in `reload' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:77:in `initialize' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:77:in `new' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:77:in `initialize' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `new' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `<top (required)>' /var/www/match-you/shared/bundle/ruby/2.6.0/bin/unicorn_rails:23:in `load' /var/www/match-you/shared/bundle/ruby/2.6.0/bin/unicorn_rails:23:in `<top (required)>' master failed to start, check stderr log for details [ec2-user@ip-172-31-38-172 current]$ bundle exec unicorn_rails -c /var/www/unicorn.rb -D -E production bundler: failed to load command: unicorn_rails (/var/www/match-you/shared/bundle/ruby/2.6.0/bin/unicorn_rails) Errno::ENOENT: No such file or directory @ rb_sysopen - /var/www/unicorn.rb /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:84:in `read' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:84:in `reload' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:77:in `initialize' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:77:in `new' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:77:in `initialize' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `new' /var/www/match-you/shared/bundle/ruby/2.6.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `<top (required)>' /var/www/match-you/shared/bundle/ruby/2.6.0/bin/unicorn_rails:23:in `load' /var/www/match-you/shared/bundle/ruby/2.6.0/bin/unicorn_rails:23:in `<top (required)>' master failed to start, check stderr log for details lessコマンドで詳細確認しようとしたのですが、表示されませんでした。 [ec2-user@ip-172-31-38-172 match-you]$ less log/unicorn.stderr.log log/unicorn.stderr.log: No such file or directory logとunicorn.stderr.logの間にcurrentを入れても同様でした。。 [ec2-user@ip-172-31-38-172 match-you]$ less log/current/unicorn.stderr.log log//current/unicorn.stderr.log: No such file or directory >ここでやるべきはデプロイのやり直しでしょう。 capistranoでデプロイのやり直しを行ったのですが、なぜかunicorn_railsmコマンド実行時と同様にgemfileの配置についてエラーが出てしまいました。。 [ec2-user@ip-172-31-38-172 match-you]$ bundle exec cap production deploy Could not locate Gemfile or .bundle/ directory gemfileに関してはこの質問を最初にさせて頂いた日から一切変更を加えていないのですが、 私が意図せず何か悪さをしてしまったのでしょうか??
yu_1985

2021/01/15 02:46 編集

> match-you/gemfile currentディレクトリではないですね…。 capistranoのデプロイ設定を見るとそこにあるのは違和感があるのですが、サーバ上のディレクトリ構成がどうなっているか確認されましたか? 当てずっぽうでパスを指定するのではなくて、lsコマンドなどでどこに何が配置されているのか確認して指定してください。 ※紛らわしいですが、「現在のディレクトリ」を指す「カレントディレクトリ」と、「capistaranoでデプロイした最新のソースがあるディレクトリのシンボリックリンク」である「currentディレクトリ」は区別してください。
shimataroo

2021/01/17 06:11 編集

返信遅くなり大変申し訳ございません。 「コメントする」を何度押しても「投稿が重複しています」と表示され送信できておりませんでした。。。 その間ビデオ通話で他の方に見て頂き、先程なんとか最後のSSL認証まで完了することができました。 長らく回答に付き合って頂いたおかげで、サーバー周りの理解を深めることができました。 かなりの時間と労力を割いて頂き、本当にありがとうございます。 ベストアンサーとさせて頂きましたので、今後とも何卒よろしくお願い致します????‍♂️
guest

0

unicornが正常に終了する場合 pidファイルを削除しますが、それなしに落ちてしまった場合、pidファイルは残ります。
ps で Unicornが動いていないのが確かなら、そういう状態ですので、pidfileを削除してください。

投稿2021/01/11 00:36

winterboum

総合スコア23347

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

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

shimataroo

2021/01/11 04:01 編集

回答頂きありがとうございます。 ファイルを確認致しました所、ご指摘の通りpidファイル(中身は空)が残っておりました。 しかし、削除後に再度unicorn_railsコマンドを実行したのですが、今度は以下の異なるエラーが吐かれてしまいました。先程、ファイル名を一旦「unicorn.conf.rb」に変更したのですが、元の「unircorn.rb」に戻しております。また、パスもこれまで「/var/www/rails/match-you/config」としていたのですが、railsは不要かと思い、「/var/www/match-you/config」としております。 <先程のエラー分> ``` [ec2-user@ip-172-31-38-172 match-you]$ bundle exec unicorn_rails -c /var/www/rails/match-you/config/unicorn.conf.rb -D -E production bundler: failed to load command: unicorn_rails (/home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails) Errno::ENOENT: No such file or directory @ rb_sysopen - /var/www/rails/match-you/config/unicorn.conf.rb ``` <今回のエラー文> [ec2-user@ip-172-31-38-172 match-you]$ bundle exec unicorn_rails -c /var/www/rails/match-you/config/[ec2-user@ip-172-31-38-172 match-you]$ bundle exec unicorn_rails -c /var/www/match-you/config/unicorn.rb -D -E production bundler: failed to load command: unicorn_rails (/home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails) Errno::ENOENT: No such file or directory @ dir_s_chdir - /var/www/current ``` 今回のエラー文についてさらにググってみたのですが、参考になりそうな情報を見つけられず大変困っております。。何か他の原因含めてアドバイス頂けますと幸いです。 ``` [ec2-user@ip-172-31-38-172 match-you]$ bundle exec unicorn_rails -c /var/www/rails/match-you/config/[ec2-user@ip-172-31-38-172 match-you]$ bundle exec unicorn_rails -c /var/www/match-you/config/unicorn.rb -D -E production bundler: failed to load command: unicorn_rails (/home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails) Errno::ENOENT: No such file or directory @ dir_s_chdir - /var/www/current ```
winterboum

2021/01/11 09:14

「railsは不要かと思い、」の根拠はなんですか?
shimataroo

2021/01/11 10:17

EC2で本アプリにディレクトリを移動する際に、以下のようになコマンドを使用していたためです。。 [ec2-user@ip-172-31-38-172 ~]$ cd /var/www/match-you
winterboum

2021/01/11 11:13

1. Capistirano で設定した deploy先dirを教えてください。 set :deploy_to のデータです 2. unicorn.conf.rb がおいてある場所を /var から教えてください。 3.unicorn.conf.rb を載せてください(質問欄を編集してそちらに)
shimataroo

2021/01/11 13:26 編集

ご返信頂きありがとうございます。以下、各々回答させて頂きます。 1.理解力悪く申し訳ございません。「config/deploy.rb」内に「set :deploy_to...」の記述を行っていないのですが、何か記述が必要ということでしょうか?? 2./var/www/match-you/config直下に置いております。 3.質問欄に編集させて頂きました。質問欄にも記載しているのですが、自動デプロイまではスクールのカリキュラムを参考に「unicorn.rb」ファイルで進めていました。しかし、ドメイン取得以降は別の記事を参照していたため、unicorn.conf.rbコマンドで実行してしまっていたことを補足させて頂きます。 一度ファイル名を「unicor.conf.rb」に変更したのですが、エラー内容が変わりありませんでしたので、現在は元の「unicorn.rb」に戻しております。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問