dev-server: add --hostname option

Change-Id: I58823690a8800484da4f7b885a95393e6f72dfff
This commit is contained in:
Brad Fitzpatrick 2013-01-27 14:05:32 -08:00
parent f6861b71e2
commit 7808fc4592
1 changed files with 3 additions and 1 deletions

View File

@ -17,6 +17,7 @@ my $opt_latency_ms = 90; # added latency in millisecond
my $opt_fast; # shortcut to disable throttling
my $opt_all; # listen on all interfaces
my $opt_hostname; # hostname to advertise, else `hostname` is used
my $opt_nobuild;
my $opt_offline; # don't use the network ("airplane mode")
my $opt_staticres; # use static resources, not those on disk
@ -45,6 +46,7 @@ GetOptions("wipe" => \$opt_wipe,
"latency_ms=i" => \$opt_latency_ms,
"fast" => \$opt_fast,
"verbose" => \$opt_verbose,
"hostname=s" => \$opt_hostname,
)
or usage();
@ -137,7 +139,7 @@ my $base = "http://localhost:$port";
my $listen = "127.0.0.1:$port";
if ($opt_all) {
$listen = "0.0.0.0:$port";
my $host = `hostname`;
my $host = $opt_hostname || `hostname`;
chomp $host;
$base = "http://$host:$port";
}