Home>
Currently, I am trying to deploy the created original app to aws according to this article https://qiita.com/naoki_mochizuki/items/5a1757d222806cbe0cd1.
So unicorn doesn't start.
bundle exec unicorn_rails -c /var/www/rails/viewhome/config/unicorn.conf.rb -D -E production
When you run
The message master failed to start, check stderr log for details is displayed.
Looking at the log, I get the following error.
INFO-: Refreshing Gem list
bundler: failed to load command: unicorn_rails (/home/kei/.rbenv/versions/2.7.1/bin/unicorn_rails)
NoMethodError: Cannot load `Rails.config.active_storage.service`:
undefined method `match'for nil: NilClass
I created the original app with reference to the rails tutorial.
I also refer to the setting of active_storage.
$heroku config: set AWS_ACCESS_KEY = $heroku config: set AWS_SECRET_KEY =<secret key>$heroku config: set AWS_REGION =<region name>$heroku config: set AWS_BUCKET =<bucket name>
And run
config/storage.yml
test: test:
service: Disk
root:<% = Rails.root.join ("tmp/storage")%>local:
service: Disk
root:<% = Rails.root.join ("storage")%>amazon:
service: S3
access_key_id:<% = ENV ['AWS_ACCESS_KEY']%>secret_access_key:<% = ENV ['AWS_SECRET_KEY']%>region:<% = ENV ['AWS_REGION']%>bucket:<% = ENV ['AWS_BUCKET']%>
config/environments/production.rb
config.active_storage.service =: amazon
It is said.
It works fine on heroku.
Is there anything I need to change or have to change?
If i know the solution, please let me know.
config/unicorn.conf.rb
#setlets
$worker = 2
$timeout = 30
$app_dir = "/ var/www/rails/viewhome"
$listen = File.expand_path'tmp/sockets/.unicorn.sock', $app_dir
$pid = File.expand_path'tmp/pids/unicorn.pid', $app_dir$std_log = File.expand_path'log/unicorn.log', $app_dir
#set config
worker_processes $worker
working_directory $app_dir
stderr_path $std_log
stdout_path $std_log
timeout $timeout
listen $listen
pid $pid
# loading booster
preload_app true
# before starting processes
before_fork do | server, worker |
defined? (ActiveRecord :: Base) and ActiveRecord :: Base.connection.disconnect!
old_pid = "# {server.config [: pid]} .oldbin"
if old_pid! = server.pid
begin begin
Process.kill "QUIT", File.read (old_pid) .to_i
rescue Errno :: ENOENT, Errno :: ESRCH
end
end
end
# after finishing processes
after_fork do | server, worker |
defined? (ActiveRecord :: Base) and ActiveRecord :: Base.establish_connection
end
Gemfile
# Bundle edge Rails instead: gem'rails', github:'rails/rails'
gem'rails','~>6.0.3','>= 6.0.3.2'
gem'mini_magick'
gem'active_storage_validations'
gem'faker'
gem'will_paginate'
gem'bootstrap-will_paginate'
gem'bootstrap-sass'
gem'jquery-rails'
gem'rails-i18n'
gem'mail-iso-2022-jp'
gem'aws-sdk-s3', '1.46.0', require: false
gem'kaminari'
#Use Puma as the app server
gem'puma','~>4.1'
#Use SCSS for stylesheets
gem'sass-rails','>= 6'
#Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem'webpacker','~>4.0'
#Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem'turbolinks','~>5'#Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem'jbuilder','~>2.7'
#Use Redis adapter to run Action Cable in production
# gem'redis','~>4.0'
# Use Active Model has_secure_password
gem'bcrypt','~>3.1.7'
# Use Active Storage variant
gem'image_processing','~>1.2'
#Reduces boot times through caching;required in config/boot.rb
gem'bootsnap','>= 1.4.2', require: false
roup: development,: test do
#Call'byebug' anywhere in the code to stop execution and get a debugger console
gem'byebug', platforms: [: mri,: mingw,: x64_mingw]
## Use sqlite3 as the database for Active Record
gem'mysql2'
gem'rspec-rails'
gem'factory_bot_rails'
gem'faker'
end
group: development do
#Access an interactive console on exception pages or by calling'console' anywhere in the code.
gem'web-console','>= 3.3.0'
gem'listen','~>3.2'
#Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem'spring'
gem'spring-watcher-listen','~>2.0.0'
gem'spring-commands-rspec'
end
group: test do
#Adds support for Capybara system testing and selenium driver
gem'rails-controller-testing'
gem'capybara','>= 2.15'
gem'selenium-webdriver'
#Easy installation and use of web drivers to run system tests with browsers
#gem'webdrivers'
#gem'chromedriver-helper'
gem'shoulda-matchers'
gem'database_cleaner'
end
group: production do
gem'mysql2'
end
group: production,: staging do
gem'unicorn', '5.4.1'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem'tzinfo-data', platforms: [: mingw,: mswin,: x64_mingw,: jruby]
-
Answer # 1
Related articles
- ruby - [rails] i can't start unicorn
- ruby on rails 5 - actioncontroller :: invalidauthenticitytoken cannot be resolved
- ruby on rails - launching unicorn doesn't work
- ruby on rails - cannot save nested child model
- ruby on rails - cannot pass id to destroy action of intermediate table
- ruby on rails 5 - the time notation cannot be written normally
- ruby on rails - image cannot be saved (activestorage installed) null in image of table
- ruby on rails - data cannot be saved in the intermediate table (parameters cannot be passed)
- ruby on rails - you cannot change the keychain after downloading the pem file when creating an ec2 instance the matter that come
- ruby on rails - vuejs cannot find element: app error
- ruby - rails s fails to start the server with a usage: rails new app_path [options] error
- ruby - rails cannot be started in the production environment when building an ec2 environment
- ruby on rails - syntax error cannot be resolved
- ruby on rails - i want to start the puma server and deploy the rails app
- ruby - heroku run rails db: cannot migrate
- ruby - aws unicorn cannot start master failed to start, check stderr log for details error
- ruby on rails - about matters that cannot be migrated
- ruby on rails - i cannot save a comment on the comment posting page
- ruby on rails runtime error cannot be resolved
Related questions
- javascript - i want to eliminate error 404
- javascript - i want to display a preview on the image post edit page
- ruby - resolve rspec mysql foreignkey error
- nginx - bundler: failed to load command: unicorn cannot start with an error saying unicorn_rails
- ruby - i'm having trouble solving the missing required keys: [: id] error
- html - i want to paste the correct link with rails6 auto_link
- ruby - i want to transition to the specified show screen
- ruby on rails - rails render: about the matter that the url after new is different
- ruby - i want to be able to purchase by pressing the purchase button
https://qiita.com/NaokiIshimura/items/2a179f2ab910992c4d39
I was able to solve it by changing the environment variables, referring to this article.