38
38
fixDBConnDelay time.Duration
39
39
fixDBConnDisableMutex bool
40
40
fixRouteWorkerPoolSize int
41
+
42
+ customerPort int
43
+ driverPort int
44
+ frontendPort int
45
+ routePort int
41
46
)
42
47
43
48
// RootCmd represents the base command when called without any subcommands
@@ -62,6 +67,13 @@ func init() {
62
67
RootCmd .PersistentFlags ().DurationVarP (& fixDBConnDelay , "fix-db-query-delay" , "D" , 300 * time .Millisecond , "Average lagency of MySQL DB query" )
63
68
RootCmd .PersistentFlags ().BoolVarP (& fixDBConnDisableMutex , "fix-disable-db-conn-mutex" , "M" , false , "Disables the mutex guarding db connection" )
64
69
RootCmd .PersistentFlags ().IntVarP (& fixRouteWorkerPoolSize , "fix-route-worker-pool-size" , "W" , 3 , "Default worker pool size" )
70
+
71
+ // Add flags to choose ports for services
72
+ RootCmd .PersistentFlags ().IntVarP (& customerPort , "customer-service-port" , "c" , 8081 , "Port for customer service" )
73
+ RootCmd .PersistentFlags ().IntVarP (& driverPort , "driver-service-port" , "d" , 8082 , "Port for driver service" )
74
+ RootCmd .PersistentFlags ().IntVarP (& frontendPort , "frontend-service-port" , "f" , 8080 , "Port for frontend service" )
75
+ RootCmd .PersistentFlags ().IntVarP (& routePort , "route-service-port" , "r" , 8083 , "Port for routing service" )
76
+
65
77
rand .Seed (int64 (time .Now ().Nanosecond ()))
66
78
logger , _ = zap .NewDevelopment (zap .AddStacktrace (zapcore .FatalLevel ))
67
79
cobra .OnInitialize (onInitialize )
@@ -90,6 +102,22 @@ func onInitialize() {
90
102
logger .Info ("fix: overriding route worker pool size" , zap .Int ("old" , config .RouteWorkerPoolSize ), zap .Int ("new" , fixRouteWorkerPoolSize ))
91
103
config .RouteWorkerPoolSize = fixRouteWorkerPoolSize
92
104
}
105
+
106
+ if customerPort != 8081 {
107
+ logger .Info ("changing customer service port" , zap .Int ("old" , 8081 ), zap .Int ("new" , customerPort ))
108
+ }
109
+
110
+ if driverPort != 8082 {
111
+ logger .Info ("changing driver service port" , zap .Int ("old" , 8082 ), zap .Int ("new" , driverPort ))
112
+ }
113
+
114
+ if frontendPort != 8080 {
115
+ logger .Info ("changing frontend service port" , zap .Int ("old" , 8080 ), zap .Int ("new" , frontendPort ))
116
+ }
117
+
118
+ if routePort != 8083 {
119
+ logger .Info ("changing route service port" , zap .Int ("old" , 8083 ), zap .Int ("new" , routePort ))
120
+ }
93
121
}
94
122
95
123
func logError (logger * zap.Logger , err error ) error {
0 commit comments