Created
March 11, 2018 11:49
-
-
Save davidsonsns/770ac0f0778412515a10ecf776c140cd to your computer and use it in GitHub Desktop.
run localtunnel forever
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const localtunnel = require('localtunnel') | |
const tunels = [{ | |
subdomain: 'youDomain', | |
local_host: 'localhost', | |
port: 4000, | |
}, { | |
subdomain: 'youDomain', | |
local_host: 'localhost', | |
port: 3000, | |
}] | |
const tlTunels = {} | |
const run = async (options, key) => { | |
tlTunels[key] = localtunnel(options.port, options, (err, tl) => { | |
if (err) { | |
run(options, key) | |
} else { | |
console.log('Running', tl.url) | |
} | |
}) | |
tlTunels[key].on('error', (e) => { | |
console.log(e) | |
run(options, key) | |
}) | |
tlTunels[key].on('close', (e) => { | |
console.log(e) | |
run(options, key) | |
}) | |
} | |
tunels.forEach((options, key) => { | |
run(options, key) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment