Fix RT#52630
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Script / Server.pm
index 80670d9..4fc199b 100644 (file)
@@ -8,6 +8,7 @@ BEGIN {
 use Moose;
 use MooseX::Types::Common::Numeric qw/PositiveInt/;
 use MooseX::Types::Moose qw/ArrayRef Str Bool Int RegexpRef/;
+use Catalyst::Utils;
 use namespace::autoclean;
 
 with 'Catalyst::ScriptRole';
@@ -27,6 +28,7 @@ has host => (
     cmd_aliases   => 'h',
     isa           => Str,
     is            => 'ro',
+    # N.B. undef (the default) means we bind on all interfaces on the host.
     documentation => 'Specify a hostname or IP on this host for the server to bind to',
 );
 
@@ -44,7 +46,9 @@ has port => (
     cmd_aliases   => 'p',
     isa           => PositiveInt,
     is            => 'ro',
-    default       => 3000,
+    default       => sub {
+        Catalyst::Utils::env_value(shift->application_name, 'port') || 3000
+    },
     documentation => 'Specify a different listening port (to the default port 3000)',
 );
 
@@ -79,7 +83,9 @@ has restart => (
     cmd_aliases   => 'r',
     isa           => Bool,
     is            => 'ro',
-    default       => 0,
+    default       => sub {
+        Catalyst::Utils::env_value(shift->application_name, 'reload') || 0;
+    },
     documentation => 'use Catalyst::Restarter to detect code changes and restart the application',
 );