Running Tasks & Consoles
Running one-off tasks on Fly can be accomplished via
fly ssh console.
To execture the
rails command on Fly, run:
fly ssh console -C "app/bin/rails db:migrate"
To list all the available tasks, run:
fly ssh console -C "app/bin/rails help"
To access an interactive Rails console, run:
fly ssh console -C "app/bin/rails console"
Then start using the console, but be careful! You're in a production environment.
To access an interactive shell, simply run:
fly ssh console
You can create Custom Rake Tasks to automate frequently used commands. As an example, add the following into
lib/tasks/fly.rake to reduce the number of keystrokes it takes to launch a console:
namespace :fly do task :ssh do sh 'fly ssh console' end task :console do sh 'fly ssh console -C "app/bin/rails console"' end task :dbconsole do sh 'fly ssh console -C "app/bin/rails dbconsole"' end end
You can run these tasks with
bin/rails fly:console, and
bin/rails fly:dbconsole respectively.