diff options
author | zeripath <art27@cantab.net> | 2020-10-19 22:03:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-19 17:03:08 -0400 |
commit | 2f1353a2f33762e10a304cbebf3a6a8d0381d316 (patch) | |
tree | b345bf060a107341c64447f7132d9e2b8d37a7b3 /routers/init.go | |
parent | 3ddf3f93d6346ac9440a7a571faea4b5c1c329be (diff) | |
download | gitea-2f1353a2f33762e10a304cbebf3a6a8d0381d316.tar.gz gitea-2f1353a2f33762e10a304cbebf3a6a8d0381d316.zip |
Move install pages out of main macaron routes (#13195)
* Move install pages out of main macaron loop
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Update templates/post-install.tmpl
Co-authored-by: Lauris BH <lauris@nix.lv>
* remove prefetch
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'routers/init.go')
-rw-r--r-- | routers/init.go | 114 |
1 files changed, 71 insertions, 43 deletions
diff --git a/routers/init.go b/routers/init.go index 793033f4a4..702acb7260 100644 --- a/routers/init.go +++ b/routers/init.go @@ -117,9 +117,46 @@ func InitLocales() { }) } +// PreInstallInit preloads the configuration to check if we need to run install +func PreInstallInit(ctx context.Context) bool { + setting.NewContext() + if !setting.InstallLock { + log.Trace("AppPath: %s", setting.AppPath) + log.Trace("AppWorkPath: %s", setting.AppWorkPath) + log.Trace("Custom path: %s", setting.CustomPath) + log.Trace("Log path: %s", setting.LogRootPath) + log.Trace("Preparing to run install page") + InitLocales() + if setting.EnableSQLite3 { + log.Info("SQLite3 Supported") + } + setting.InitDBConfig() + svg.Init() + } + + return !setting.InstallLock +} + +// PostInstallInit rereads the settings and starts up the database +func PostInstallInit(ctx context.Context) { + setting.NewContext() + setting.InitDBConfig() + if setting.InstallLock { + if err := initDBEngine(ctx); err == nil { + log.Info("ORM engine initialization successful!") + } else { + log.Fatal("ORM engine initialization failed: %v", err) + } + svg.Init() + } +} + // GlobalInit is for global configuration reload-able. func GlobalInit(ctx context.Context) { setting.NewContext() + if !setting.InstallLock { + log.Fatal("Gitea is not installed") + } if err := git.Init(ctx); err != nil { log.Fatal("Git module init failed: %v", err) } @@ -134,59 +171,50 @@ func GlobalInit(ctx context.Context) { NewServices() - if setting.InstallLock { - highlight.NewContext() - external.RegisterParsers() - markup.Init() - if err := initDBEngine(ctx); err == nil { - log.Info("ORM engine initialization successful!") - } else { - log.Fatal("ORM engine initialization failed: %v", err) - } + highlight.NewContext() + external.RegisterParsers() + markup.Init() + if err := initDBEngine(ctx); err == nil { + log.Info("ORM engine initialization successful!") + } else { + log.Fatal("ORM engine initialization failed: %v", err) + } - if err := models.InitOAuth2(); err != nil { - log.Fatal("Failed to initialize OAuth2 support: %v", err) - } + if err := models.InitOAuth2(); err != nil { + log.Fatal("Failed to initialize OAuth2 support: %v", err) + } - models.NewRepoContext() + models.NewRepoContext() - // Booting long running goroutines. - cron.NewContext() - issue_indexer.InitIssueIndexer(false) - code_indexer.Init() - if err := stats_indexer.Init(); err != nil { - log.Fatal("Failed to initialize repository stats indexer queue: %v", err) - } - mirror_service.InitSyncMirrors() - webhook.InitDeliverHooks() - if err := pull_service.Init(); err != nil { - log.Fatal("Failed to initialize test pull requests queue: %v", err) - } - if err := task.Init(); err != nil { - log.Fatal("Failed to initialize task scheduler: %v", err) - } - eventsource.GetManager().Init() + // Booting long running goroutines. + cron.NewContext() + issue_indexer.InitIssueIndexer(false) + code_indexer.Init() + if err := stats_indexer.Init(); err != nil { + log.Fatal("Failed to initialize repository stats indexer queue: %v", err) } + mirror_service.InitSyncMirrors() + webhook.InitDeliverHooks() + if err := pull_service.Init(); err != nil { + log.Fatal("Failed to initialize test pull requests queue: %v", err) + } + if err := task.Init(); err != nil { + log.Fatal("Failed to initialize task scheduler: %v", err) + } + eventsource.GetManager().Init() + if setting.EnableSQLite3 { log.Info("SQLite3 Supported") } checkRunMode() - // Now because Install will re-run GlobalInit once it has set InstallLock - // we can't tell if the ssh port will remain unused until that's done. - // However, see FIXME comment in install.go - if setting.InstallLock { - if setting.SSH.StartBuiltinServer { - ssh.Listen(setting.SSH.ListenHost, setting.SSH.ListenPort, setting.SSH.ServerCiphers, setting.SSH.ServerKeyExchanges, setting.SSH.ServerMACs) - log.Info("SSH server started on %s:%d. Cipher list (%v), key exchange algorithms (%v), MACs (%v)", setting.SSH.ListenHost, setting.SSH.ListenPort, setting.SSH.ServerCiphers, setting.SSH.ServerKeyExchanges, setting.SSH.ServerMACs) - } else { - ssh.Unused() - } - } - - if setting.InstallLock { - sso.Init() + if setting.SSH.StartBuiltinServer { + ssh.Listen(setting.SSH.ListenHost, setting.SSH.ListenPort, setting.SSH.ServerCiphers, setting.SSH.ServerKeyExchanges, setting.SSH.ServerMACs) + log.Info("SSH server started on %s:%d. Cipher list (%v), key exchange algorithms (%v), MACs (%v)", setting.SSH.ListenHost, setting.SSH.ListenPort, setting.SSH.ServerCiphers, setting.SSH.ServerKeyExchanges, setting.SSH.ServerMACs) + } else { + ssh.Unused() } + sso.Init() svg.Init() } |