@@ -44,6 +44,7 @@ const (
4444
4545 // Flags (that can also be env vars)
4646 localFlag = "local"
47+ addressFlag = "address"
4748 healthDisabledFlag = "health-disabled"
4849 healthTimeoutFlag = "health-timeout"
4950 healthInitialDelayFlag = "health-initial-delay"
@@ -56,12 +57,14 @@ func init() {
5657
5758func main () {
5859 viper .SetDefault (localFlag , false )
60+ viper .SetDefault (addressFlag , "localhost" )
5961 viper .SetDefault (healthDisabledFlag , false )
6062 viper .SetDefault (healthTimeoutFlag , 5 )
6163 viper .SetDefault (healthInitialDelayFlag , 5 )
6264 viper .SetDefault (healthFailureThresholdFlag , 3 )
6365 pflag .Bool (localFlag , viper .GetBool (localFlag ),
6466 "Set this, or LOCAL env, to 'true' to run this binary in local development mode. Defaults to 'false'" )
67+ pflag .String (addressFlag , viper .GetString (addressFlag ), "The address to bind the server port to. Defaults to 'localhost" )
6568 pflag .Bool (healthDisabledFlag , viper .GetBool (healthDisabledFlag ),
6669 "Set this, or HEALTH_ENABLED env, to 'true' to enable health checking on the GameServer. Defaults to 'true'" )
6770 pflag .Int64 (healthTimeoutFlag , viper .GetInt64 (healthTimeoutFlag ),
@@ -83,19 +86,21 @@ func main() {
8386 runtime .Must (viper .BindPFlags (pflag .CommandLine ))
8487
8588 isLocal := viper .GetBool (localFlag )
89+ address := viper .GetString (addressFlag )
8690 healthDisabled := viper .GetBool (healthDisabledFlag )
8791 healthTimeout := time .Duration (viper .GetInt64 (healthTimeoutFlag )) * time .Second
8892 healthInitialDelay := time .Duration (viper .GetInt64 (healthInitialDelayFlag )) * time .Second
8993 healthFailureThreshold := viper .GetInt64 (healthFailureThresholdFlag )
9094
91- logrus .WithField (localFlag , isLocal ).WithField ("version" , pkg .Version ).WithField ("port" , port ).
95+ logrus .WithField (localFlag , isLocal ).WithField ("version" , pkg .Version ).
96+ WithField ("port" , port ).WithField (addressFlag , address ).
9297 WithField (healthDisabledFlag , healthDisabled ).WithField (healthTimeoutFlag , healthTimeout ).
9398 WithField (healthFailureThresholdFlag , healthFailureThreshold ).
9499 WithField (healthInitialDelayFlag , healthInitialDelay ).Info ("Starting sdk sidecar" )
95100
96- lis , err := net .Listen ("tcp" , fmt .Sprintf ("localhost :%d" , port ))
101+ lis , err := net .Listen ("tcp" , fmt .Sprintf ("%s :%d" , address , port ))
97102 if err != nil {
98- logrus .WithField ("port" , port ).Fatalf ("Could not listen on port" )
103+ logrus .WithField ("port" , port ).WithField ( "address" , address ). Fatalf ("Could not listen on port" )
99104 }
100105 grpcServer := grpc .NewServer ()
101106
0 commit comments