Skip to content

Instantly share code, notes, and snippets.

@davidsonsns
Created March 11, 2018 11:49
Show Gist options
  • Save davidsonsns/770ac0f0778412515a10ecf776c140cd to your computer and use it in GitHub Desktop.
Save davidsonsns/770ac0f0778412515a10ecf776c140cd to your computer and use it in GitHub Desktop.
run localtunnel forever
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