Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

How to start and stop ngrok with Thin server?

Servers • Asked by Daniel Weaver
I'm using the basic Thin server on my dev machine and I'd like to start and stop ngrok automatically with `rails s` - how do I do that?

I found several articles but they all involve more complex setups running unicorn, or another server, or using the ngrok-tunnel gem. I'm looking for a simpler solution. I was hoping I could write a simple rake task like:

desc 'Starts rails server and ngrok'
task :start do
  Process.exec("thin start")
  Process.exec("ngrok http 3000 -subdomain=mysubdomain")

Then just `rake start`, but of course only the first process runs and ngrok never starts.

Foreman is built for this. I use it to start rails, sidekiq and guard-rspec.

Install the gem, and add a Procfile(.dev)

web:    bundle exec thin start -p $PORT
worker: bundle exec rake resque:work QUEUE=*

Great, thanks. I was hoping for a solution that didn't require another gem but I'll give this a try. 

Unfortunately using a gem in this case is one of the best solution.

Agreed on using foreman.  It's the easiest way, unless you want to setup some bash script as your entry point that launches both.  In this case foreman is great as the other posters have mentioned.

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 31,353+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.