Skip to content

Instantly share code, notes, and snippets.

@tjmcewan
Last active October 12, 2016 03:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjmcewan/e3d3ac7a2d3ba1d3acfd04c88061b0a8 to your computer and use it in GitHub Desktop.
Save tjmcewan/e3d3ac7a2d3ba1d3acfd04c88061b0a8 to your computer and use it in GitHub Desktop.
localtunnel restarter. all props to @michaelkeenan. slightly modified to be run as a executable & to remove ordinal numbers. original here: https://github.com/localtunnel/localtunnel/issues/81#issuecomment-218320442
#!/usr/bin/env ruby
require 'optparse'
options = {:subdomain => 'defaultdomain', :port => 3000}
parser = OptionParser.new do|opts|
opts.banner = "Usage: localtunnel [options]"
opts.on('-s', '--subdomain subdomain', 'Subdomain') do |subdomain|
options[:subdomain] = subdomain;
end
opts.on('-p', '--port port', 'Port') do |port|
options[:port] = port;
end
opts.on('-h', '--help', 'Displays Help') do
puts opts
exit
end
end
parser.parse!
restart_count = 0
while true
`lt --port #{options[:port]} --subdomain #{options[:subdomain]}`
restart_count += 1
puts "times restarted: #{restart_count}"
end
@tjmcewan
Copy link
Author

put it in your path somewhere and run chmod +x localtunnel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment