Ngrok: Daemon / Silent Mode

Created on 23 Nov 2013  路  17Comments  路  Source: inconshreveable/ngrok

I am running ngrok in a vagrant box via puppet and it seems to error out when I start the service which I assume is because of the interface being returned. It would be great to run ngrok --daemon 80 or --silent which would only return a 0 status if successful or the error. If such an option does already exist I didnt see it on the help pages or in the code anywhere.

Most helpful comment

As of version 2.0.24, ngrok http 80 --log=stdout > ngrok.log & did the trick.

All 17 comments

I thought I'd replied to this. ngrok does let you supply -log=stdout which will turn off the console interface and just display streaming log output over stdout. There is no daemon mode and I don't intend on adding one. I think daemonizing services is almost always better left to a supervising framework like runit/upstart/supervisor/etc.

You did, this was posted before your reply. Thanks for the tip.

@inconshreveable I'd be fine if this solution actually let you run the thing in the background, but running something like:

ngrok -log="$HOME/ngrok.log" 80 &

doesn't even allow you to background the job. It fails with a:

suspended (tty output)  ngrok -log="$HOME/ngrok.log" 80

If I have a config file, I need zero output from ngrok on what it's doing 99% of the time. The -log should disable the "dashboard" screen on what is connected, for how long and on which interfaces. Either that or there should be a -quiet option which does the equivalent thing.

@inconshreveable also, I can see where you're coming from regarding "daemonizing", however, you have to consider your tool may be used by those who:

a. cannot understand how those services work (eg, explaining to a non-technical QA person how to set it up)
b. don't need the overhead of a "supervising framework" when all they want to do is run ngrok in the background for a few hours so they can pair with someone

I'm currently trying to work on my shellfiles so they can be used by our developers to abstract away whether they are using localtunnel, ngrok, pagekite, etc. All of the other services offer some sort of "run this thing without any terminal output" except for ngrok. So if I'm to support ngrok, I not only have to know if ngrok is installed, but I _also_ have to check to see which type of "supervising framework" they have installed, figure out whether it's configured to run ngrok, and finally execute the proper command for that framework to start ngrok.

That's a lot of extra work for something that is as simple as "route all output to a log file" and optionally "drop a PID file somewhere".

@jfelchner That's good feedback. I think you can get what you want now with:

ngrok -log=stdout 80 > /dev/null &

Or if you want a log:

ngrok -log=stdout 80 > ngrok.log &

This is a very unintuitive UI. "-log=stdout" really means "disable the terminal UI", which is surprising and not well documented.

I've recently discovered that it's possible for a program to detect whether it's attached to a tty or not and adjust its UI accordingly. I'll probably use that in the next version of ngrok to disable the terminal UI when run under supervisors or in the background, as well as possibly splitting out "do I run the terminal ui" into a separate option (or at least configuration file parameter).

With regard to a daemonization: it seems like if the "&" operator works as you expect it to, that it becomes unnecessary to have a daemon option. Do you disagree?

@inconshreveable if the & option works and I can get everything logged to a file, then I don't think a -daemon option is necessary.

I'll try out your solution above and get back with you.

Thanks for the reply!

This worked for me!

ngrok -log=stdout 80 > /dev/null &

@rwestergren me too. :)

As soon as Github actually gets a "here is a list of all the issues you're subscribed to", stuff like this won't fall through the cracks.

Just wanted to let you know that I've run into the same UX issue and a --quiet or similar flag would have been more obvious.

'scuse my probably stupidity, but how would I get -log=stdout > /dev/null & to work with ssh forwarding, for example, something like this:

./ngrok -subdomain=foo -authtoken barxyz -proto=tcp 22

I can't figure out where the 'tcp' declaration would go.

Someone know how to log -proto=tcp 22 ?

I was successful using a tunnel for ssh in the config file and running
ngrok -log=stdout > /dev/null start ssh &

my config file looks like this

tunnels:
  ssh:
    remote_port: 50800
    proto:
      tcp: 22

When I try ngrok -log=stdout 80 > ~/ngrok.log & with v2.0.19, the output I get is the command instructions as though I entered an invalid parameter.

@selfagency same issue here, the -log is the problem, how to achieve the same thing with the new version?

As of version 2.0.24, ngrok http 80 --log=stdout > ngrok.log & did the trick.

@gnhuy91 Doesn't this fill up the log file and cause waste of memory? I mean, does log rotation need to be turned on??

@IgorGanapolsky yea you should bring up your own solution, but anw above command no longer available.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IngwiePhoenix picture IngwiePhoenix  路  7Comments

owlstack picture owlstack  路  5Comments

ricardopieper picture ricardopieper  路  3Comments

jabooth picture jabooth  路  5Comments

shubhamk1997 picture shubhamk1997  路  5Comments