Running the Application with the bin/run Command
Learn about executing the Rails application through the bin/run command.
We'll cover the following
Let’s run our application
Currently, we can run our Rails app like so:
bin/rails server --binding=0.0.0.0
While this is easy enough to remember, our app will one day require more complex commands to run it locally. Following our pattern of using scripts instead of documentation, we’ll create bin/run
to wrap bin/rails
server.
This will be a bash script since it currently just needs to run one command. The first line indicates this to the operating system, and we’ll call set -e
so that we fail the script if any command it calls fails. And then we call the bin/rails
server:
# bin/run #!/usr/bin/env bash set -e
# We must bind to 0.0.0.0 inside a
# Docker container or the port won’t forward
bin/rails server --binding=0.0.0.0
The following command needs to be executable:
chmod +x bin/run
The following is the output of the bun/run
command:
Get hands-on with 1400+ tech skills courses.