Ask A Question

Notifications

You’re not receiving notifications from this thread.

How to start and stop ngrok with Thin server?

Daniel Weaver asked in Servers
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")
end

Then just `rake start`, but of course only the first process runs and ngrok never starts.
Reply
Great, thanks. I was hoping for a solution that didn't require another gem but I'll give this a try. 
Reply
Unfortunately using a gem in this case is one of the best solution.
Reply
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.
Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 85,376+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.