EC2内でRailsを起動させるべく
[ec2-user@ip-172-31-23-189 <リポジトリ名>]$ bundle exec unicorn_rails -c config/unicorn.rb -E production -D
のコマンドを入力するする時にエラーがは発生しました。
ターミナルに
Your RubyGems version (3.0.3) has a bug that prevents required_ruby_version
from working for Bundler. Any scripts that use gem install bundler
will break as soon as Bundler drops support for your Ruby version. Please upgrade RubyGems to avoid future breakage and silence this warning by running gem update --system 3.2.3
bundler: command not found: unicorn_rails
Install missing gem executables with bundle install
と表示されてしまい、うまく起動ていません。
まず、Gemfileの記述や、unicorn.rbをか確認しました。
Gemfile
group :production do
gem 'pg'
gem 'unicorn', '5.4.1'
end
unicorn.rb
#サーバ上でのアプリケーションコードが設置されているディレクトリを変数に入れておく
app_path = File.expand_path('../../', FILE)
#アプリケーションサーバの性能を決定する
worker_processes 1
#アプリケーションの設置されているディレクトリを指定
working_directory app_path
#Unicornの起動に必要なファイルの設置場所を指定
pid "#{app_path}/tmp/pids/unicorn.pid"
#ポート番号を指定
listen 3000
#エラーのログを記録するファイルを指定
stderr_path "#{app_path}/log/unicorn.stderr.log"
#通常のログを記録するファイルを指定
stdout_path "#{app_path}/log/unicorn.stdout.log"
#Railsアプリケーションの応答を待つ上限時間を設定
timeout 60
#以下は応用的な設定なので説明は割愛
preload_app true
GC.respond_to?(:copy_on_write_friendly=) && GC.copy_on_write_friendly = true
check_client_connection false
run_once = true
before_fork do |server, worker|
defined?(ActiveRecord::Base) &&
ActiveRecord::Base.connection.disconnect!
if run_once
run_once = false # prevent from firing again
end
old_pid = "#{server.config[:pid]}.oldbin"
if File.exist?(old_pid) && server.pid != old_pid
begin
sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
Process.kill(sig, File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH => e
logger.error e
end
end
end
after_fork do |_server, _worker|
defined?(ActiveRecord::Base) && ActiveRecord::Base.establish_connection
end
というという記述をか確認しました。
カリキュラムのとの通りになっていました。
そしてつ次にいインストールができ出来ていないと思い、eEC2とろローカルと共にbundle ininstallを実行しました。
そうしたら、
ローカル環境ではunicornがあありそうなのですが、
EC2にunicornがみつか見つかりませんでした。
rbenvのrehashし忘れや、bundlerのい入れ忘れもか考え、それぞれ、rbenv rehashとgem install bundler -v 2.4.3も行ってみましたが、同じエラーがずずっとで出ています。
アドバイス等いただけたらさ幸いです
あなたの回答
tips
プレビュー