-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Fix --port setting #13288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix --port setting #13288
Changes from 1 commit
d494f2d
64ef829
42e97aa
26a6204
903d63e
6bdd2d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,11 @@ and it takes care of all the other things for you`, | |
Value: "3000", | ||
Usage: "Temporary port number to prevent conflict", | ||
}, | ||
cli.StringFlag{ | ||
Name: "install-port", | ||
Value: "3000", | ||
Usage: "Temporary port number to run the install page on to prevent conflict", | ||
}, | ||
cli.StringFlag{ | ||
Name: "pid, P", | ||
Value: setting.PIDFile, | ||
|
@@ -116,16 +121,20 @@ func runWeb(ctx *cli.Context) error { | |
setting.WritePIDFile = true | ||
} | ||
|
||
// Flag for port number in case first time run conflict. | ||
if ctx.IsSet("port") { | ||
if err := setPort(ctx.String("port")); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
// Perform pre-initialization | ||
needsInstall := routers.PreInstallInit(graceful.GetManager().HammerContext()) | ||
if needsInstall { | ||
// Flag for port number in case first time run conflict | ||
if ctx.IsSet("port") { | ||
if err := setPort(ctx.String("port")); err != nil { | ||
return err | ||
} | ||
} | ||
if ctx.IsSet("install-port") { | ||
if err := setPort(ctx.String("install-port")); err != nil { | ||
return err | ||
} | ||
} | ||
m := routes.NewMacaron() | ||
routes.RegisterInstallRoute(m) | ||
err := listen(m, false) | ||
|
@@ -152,6 +161,12 @@ func runWeb(ctx *cli.Context) error { | |
// Perform global initialization | ||
routers.GlobalInit(graceful.GetManager().HammerContext()) | ||
|
||
// Override the provided port number within the configuration | ||
if ctx.IsSet("port") { | ||
if err := setPort(ctx.String("port")); err != nil { | ||
return err | ||
} | ||
} | ||
// Set up Macaron | ||
m := routes.NewMacaron() | ||
routes.RegisterRoutes(m) | ||
|
@@ -190,10 +205,6 @@ func setPort(port string) error { | |
defaultLocalURL += ":" + setting.HTTPPort + "/" | ||
|
||
cfg.Section("server").Key("LOCAL_ROOT_URL").SetValue(defaultLocalURL) | ||
|
||
if err := cfg.SaveTo(setting.CustomConf); err != nil { | ||
return fmt.Errorf("Error saving generated JWT Secret to custom config: %v", err) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. --port states that it is temporary so it shouldn't write to the ini... however, this is going to break gitea serv, admin, manager etc. I just don't know what to do here. In terms of doing a pure bugfix for the linked Issue only this change should be dropped but it's really hard to know what to do here. |
||
} | ||
return nil | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ Starts the server: | |
|
||
- Options: | ||
- `--port number`, `-p number`: Port number. Optional. (default: 3000). Overrides configuration file. | ||
- `--install-port number`: Port number to run the install page on. Optional. (default: 3000). Overrides configuration file. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this change could be another PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's part of the fix really. If you make --port apply both before the install page and after the install page then the PORT option in the install page is irrelevant and it is overwritten. If you make --port only apply once then if there is a graceful restart after install the port that gitea runs on will change. If you make --port only apply to the install page then that may change behaviour for other people. In this case the only solution is provide a separate option for the install page then you can have a consistent solution. |
||
- `--pid path`, `-P path`: Pidfile path. Optional. | ||
- Examples: | ||
- `gitea web` | ||
|
Uh oh!
There was an error while loading. Please reload this page.