@@ -41,6 +41,11 @@ and it takes care of all the other things for you`,
4141 Value : "3000" ,
4242 Usage : "Temporary port number to prevent conflict" ,
4343 },
44+ cli.StringFlag {
45+ Name : "install-port" ,
46+ Value : "3000" ,
47+ Usage : "Temporary port number to run the install page on to prevent conflict" ,
48+ },
4449 cli.StringFlag {
4550 Name : "pid, P" ,
4651 Value : setting .PIDFile ,
@@ -116,16 +121,20 @@ func runWeb(ctx *cli.Context) error {
116121 setting .WritePIDFile = true
117122 }
118123
119- // Flag for port number in case first time run conflict.
120- if ctx .IsSet ("port" ) {
121- if err := setPort (ctx .String ("port" )); err != nil {
122- return err
123- }
124- }
125-
126124 // Perform pre-initialization
127125 needsInstall := routers .PreInstallInit (graceful .GetManager ().HammerContext ())
128126 if needsInstall {
127+ // Flag for port number in case first time run conflict
128+ if ctx .IsSet ("port" ) {
129+ if err := setPort (ctx .String ("port" )); err != nil {
130+ return err
131+ }
132+ }
133+ if ctx .IsSet ("install-port" ) {
134+ if err := setPort (ctx .String ("install-port" )); err != nil {
135+ return err
136+ }
137+ }
129138 m := routes .NewMacaron ()
130139 routes .RegisterInstallRoute (m )
131140 err := listen (m , false )
@@ -152,6 +161,12 @@ func runWeb(ctx *cli.Context) error {
152161 // Perform global initialization
153162 routers .GlobalInit (graceful .GetManager ().HammerContext ())
154163
164+ // Override the provided port number within the configuration
165+ if ctx .IsSet ("port" ) {
166+ if err := setPort (ctx .String ("port" )); err != nil {
167+ return err
168+ }
169+ }
155170 // Set up Macaron
156171 m := routes .NewMacaron ()
157172 routes .RegisterRoutes (m )
@@ -190,7 +205,6 @@ func setPort(port string) error {
190205 defaultLocalURL += ":" + setting .HTTPPort + "/"
191206
192207 cfg .Section ("server" ).Key ("LOCAL_ROOT_URL" ).SetValue (defaultLocalURL )
193-
194208 if err := cfg .SaveTo (setting .CustomConf ); err != nil {
195209 return fmt .Errorf ("Error saving generated JWT Secret to custom config: %v" , err )
196210 }
0 commit comments