@@ -16,9 +16,8 @@ import (
16
16
"code.gitea.io/gitea/modules/graceful"
17
17
"code.gitea.io/gitea/modules/log"
18
18
"code.gitea.io/gitea/modules/setting"
19
- "code.gitea.io/gitea/modules/util"
20
19
"code.gitea.io/gitea/routers"
21
- "code.gitea.io/gitea/routers/routes "
20
+ "code.gitea.io/gitea/routers/install "
22
21
23
22
context2 "github.com/gorilla/context"
24
23
"github.com/urfave/cli"
@@ -89,7 +88,7 @@ func runWeb(ctx *cli.Context) error {
89
88
}
90
89
91
90
// Perform pre-initialization
92
- needsInstall := routers . PreInstallInit (graceful .GetManager ().HammerContext ())
91
+ needsInstall := install . PreloadSettings (graceful .GetManager ().HammerContext ())
93
92
if needsInstall {
94
93
// Flag for port number in case first time run conflict
95
94
if ctx .IsSet ("port" ) {
@@ -102,7 +101,7 @@ func runWeb(ctx *cli.Context) error {
102
101
return err
103
102
}
104
103
}
105
- c := routes . InstallRoutes ()
104
+ c := install . Routes ()
106
105
err := listen (c , false )
107
106
select {
108
107
case <- graceful .GetManager ().IsShutdown ():
@@ -135,7 +134,7 @@ func runWeb(ctx *cli.Context) error {
135
134
}
136
135
137
136
// Set up Chi routes
138
- c := routes .NormalRoutes ()
137
+ c := routers .NormalRoutes ()
139
138
err := listen (c , true )
140
139
<- graceful .GetManager ().Done ()
141
140
log .Info ("PID: %d Gitea Web Finished" , os .Getpid ())
@@ -152,19 +151,6 @@ func setPort(port string) error {
152
151
case setting .FCGI :
153
152
case setting .FCGIUnix :
154
153
default :
155
- // Save LOCAL_ROOT_URL if port changed
156
- cfg := ini .Empty ()
157
- isFile , err := util .IsFile (setting .CustomConf )
158
- if err != nil {
159
- log .Fatal ("Unable to check if %s is a file" , err )
160
- }
161
- if isFile {
162
- // Keeps custom settings if there is already something.
163
- if err := cfg .Append (setting .CustomConf ); err != nil {
164
- return fmt .Errorf ("Failed to load custom conf '%s': %v" , setting .CustomConf , err )
165
- }
166
- }
167
-
168
154
defaultLocalURL := string (setting .Protocol ) + "://"
169
155
if setting .HTTPAddr == "0.0.0.0" {
170
156
defaultLocalURL += "localhost"
@@ -173,10 +159,10 @@ func setPort(port string) error {
173
159
}
174
160
defaultLocalURL += ":" + setting .HTTPPort + "/"
175
161
176
- cfg . Section ( "server" ). Key ( " LOCAL_ROOT_URL" ). SetValue ( defaultLocalURL )
177
- if err := cfg . SaveTo ( setting . CustomConf ); err != nil {
178
- return fmt . Errorf ( "Error saving generated LOCAL_ROOT_URL to custom config: %v" , err )
179
- }
162
+ // Save LOCAL_ROOT_URL if port changed
163
+ setting . CreateOrAppendToCustomConf ( func ( cfg * ini. File ) {
164
+ cfg . Section ( "server" ). Key ( " LOCAL_ROOT_URL" ). SetValue ( defaultLocalURL )
165
+ })
180
166
}
181
167
return nil
182
168
}
0 commit comments