ngrok-daemon
Very basic Node.js ngrok wrapper. Unline ngrok
npm package, ngrok-daemon do not use child_process
so:
- ngrok tunnel won't be killed automatically,
- logs are streamed to file,
- you have the ngrok PID.
It's really basic so you will get only start
, stop
and isRunning
functions.
Installation
To install ngrok-daemon you need to run npm install
:
npm install ngrok-daemon --save
ngrok-daemons uses native Promise
object,
so it won't run on outdated Node.js.
API
API is small and simple. Every function returns Promise
.
When ngrok-daemon fails to perform some action, it rejects the promise.
start
Start ngrok on given port and get tunnel
object:
var ngrok =ngrokstart4000 // Port
Important: Node.js process won't exit automatically after spawning
background process, so if you need to stop it, call process.exit
once
you got a tunnel data.
It's possible to specify custom shell script that will start ngrok. To do it, pass source string as an option:
ngrokstart'ngrok -log=stdout 4000'
stop
Stop ngrok process using the PID:
ngrok
It's possible to specify custom shell script that will stop ngrok. To do it, pass source string as the first argument:
ngrok
isRunning
Resolves promise if it is running and rejects if isn't:
ngrok
It's possible to specify custom shell script that will check if ngrok is running. To do it, pass source string as the first argument:
ngrok
Important: empty stdout will be treated as "not running" and vice versa.
Tests
To run the tests you need:
- Internet connection,
- free port
4999
, ngrok
binary avaliable in$PATH
,
To start the tests in "watch" (autotests) mode:
npm test
Warning: killall ngrok
will be invoked after each it
statement,
so don't be surprised when your own ngrok tunnel will be killed.
License
ngrok-daemon is released under the MIT License.