diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-05-25 11:47:30 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-25 03:47:30 +0000 |
commit | 5f39285d6d3f365a44a828b0d8e7c5e0928a32f0 (patch) | |
tree | c291b105bda142620af94c0c666f5fc5c86fea1a /modules/setting | |
parent | 694b38b880b28cf0b6f643a02617e8652972e57c (diff) | |
download | gitea-5f39285d6d3f365a44a828b0d8e7c5e0928a32f0.tar.gz gitea-5f39285d6d3f365a44a828b0d8e7c5e0928a32f0.zip |
Improve RunMode / dev mode (#24886)
1. non-dev mode is treated as prod mode, to protect users from
accidentally running in dev mode if there is a typo in this value.
2. in dev mode, do not need to really exit if there are template errors,
because the template errors could be fixed by developer soon and the
templates get reloaded, help:
* https://github.com/go-gitea/gitea/issues/24845#issuecomment-1557615382
3. Fine tune the mail template loading message.
Diffstat (limited to 'modules/setting')
-rw-r--r-- | modules/setting/setting.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 8f20ef0856..71cd9a12a9 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -251,7 +251,13 @@ func loadRunModeFrom(rootCfg ConfigProvider) { if RunMode == "" { RunMode = rootSec.Key("RUN_MODE").MustString("prod") } - IsProd = strings.EqualFold(RunMode, "prod") + + // non-dev mode is treated as prod mode, to protect users from accidentally running in dev mode if there is a typo in this value. + RunMode = strings.ToLower(RunMode) + if RunMode != "dev" { + RunMode = "prod" + } + IsProd = RunMode != "dev" // check if we run as root if os.Getuid() == 0 { |