Guest User

Untitled

a guest
Mar 20th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. const localtunnel = require('localtunnel')
  2.  
  3. const tunels = [{
  4. subdomain: 'youDomain',
  5. local_host: 'localhost',
  6. port: 4000,
  7. }, {
  8. subdomain: 'youDomain',
  9. local_host: 'localhost',
  10. port: 3000,
  11. }]
  12.  
  13. const tlTunels = {}
  14.  
  15. const run = async (options, key) => {
  16. tlTunels[key] = localtunnel(options.port, options, (err, tl) => {
  17. if (err) {
  18. run(options, key)
  19. } else {
  20. console.log('Running', tl.url)
  21. }
  22. })
  23.  
  24. tlTunels[key].on('error', (e) => {
  25. console.log(e)
  26. run(options, key)
  27. })
  28.  
  29. tlTunels[key].on('close', (e) => {
  30. console.log(e)
  31. run(options, key)
  32. })
  33. }
  34.  
  35. tunels.forEach((options, key) => {
  36. run(options, key)
  37. })
Add Comment
Please, Sign In to add comment