Here are the steps to get Rails to start locally in production mode.
This time, only the steps required to use Rails as an API server.
To check the operation, you can set the same settings as when you started in development mode except for the DB name. If it is the same as when rails new, it should look like this.
database.yml
default: &default
adapter: mysql2
encoding: utf8mb4
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password:
host: localhost
development:
<<: *default
database: my_app_development
test:
<<: *default
database: my_app_test
production:
<<: *default
database: my_app_production
% RAILS_ENV=production bundle exec rails db:setup
Created database 'my_app_production'
Just db: setup
should do db: create, db: migrate, db: seed.
$ bundle exec rails s -e production
If you can confirm access with curl etc., it's OK.
The application that I confirmed to work had sidekiq installed, so I accessed / sidekiq
, but it worked fine.
Did it work so easily, even though it's just an API server?
I wonder if it's easier than it used to be.
Recommended Posts