-
Notifications
You must be signed in to change notification settings - Fork 2
How do I debug a Rails application while using foreman?
I want to use
binding.pryin a part of my ruby application that is started with foreman but when I do that I get a confusing experience with logs printing out and I can't see what I type into the ruby repl. How can I make this usable?
Because of how foreman works, it interferes with command-line interaction in a not ideal way, which makes it very difficult to do anything other than puts debugging. But! foreman has easy to use options you can use to work around that.
One can start up foreman with less than all of the processes it manages using its formation parameter (-m) and a combination of on/off switches.
An example Procfile:
web: bundle exec rails s --binding 0.0.0.0 --port $PORT --pid=tmp/pids/web.pid
worker: bundle exec sidekiq -v -C config/sidekiq.yml
webpack: bin/webpack-dev-server
If you want to run a binding.pry command inside your sidekiq process, you could start foreman like so:
foreman start -m 'all=1,worker=0'
And then in another terminal, you can begin sidekiq with the command from the Procfile above:
bundle exec sidekiq -v -C config/sidekiq.yml
Now when you run a job through that worker with a binding.pry, you will get the pry prompt in your terminal running sidekiq.
There are more options for foreman in the manpages: http://ddollar.github.io/foreman/
🏳️🌈🦄 Sharing is caring. 🦄🏳️🌈
TODO: can we recreate the tag system here roughly with sections about certain subjects?