How to Run My Ruby Code After Rails Server Start

rails 5 run script only after server start

The config.ru file is only used by web servers and not loaded by the console script, rake tasks or even your test suite. What you put there is only executed when a server instance launches.

Web servers themselves have also ways to do this. When you use Puma for instance, there are hooks like on_worker_boot or after_worker_boot, which may come to help (http://www.rubydoc.info/github/puma/puma/Puma/Configuration/DSL).

However, I'd recommend integrating this into your deployed server environment and out of the Rails app.

How to use Rails Console after I run rails server

After you run "rails s" open a new tab in the terminal (make sure that it is the same directory) and run rails console. The database it will be referring to in the console is the one being run by rails s.

How to start rails server?

In a Rails 2.3 app it is just ./script/server start



Related Topics



Leave a reply



Submit