feat. add discussion_server setting configuration

This commit is contained in:
cloudchamb3r 2024-08-01 12:11:51 +09:00
parent f9c73568c5
commit 0390e49210

AI 샘플 코드 생성 중입니다

Loading...
3 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,20 @@
package setting
import "fmt"
var DiscussionServer = struct {
Host string
Port int
Url string
}{
Host: "localhost",
Port: 8081,
Url: "http://localhost:8081",
}
func loadDiscussionServerFrom(rootCfg ConfigProvider) {
sec := rootCfg.Section("discussion_server")
DiscussionServer.Host = sec.Key("HOST").MustString("localhost")
DiscussionServer.Port = sec.Key("PORT").MustInt(8081)
DiscussionServer.Url = fmt.Sprintf("http://%s:%d", DiscussionServer.Host, DiscussionServer.Port)
}

View File

@ -118,6 +118,7 @@ func loadCommonSettingsFrom(cfg ConfigProvider) error {
loadLogGlobalFrom(cfg)
loadServerFrom(cfg)
loadSSHFrom(cfg)
loadDiscussionServerFrom(cfg)
mustCurrentRunUserMatch(cfg) // it depends on the SSH config, only non-builtin SSH server requires this check

View File

@ -399,6 +399,10 @@ func SubmitInstall(ctx *context.Context) {
cfg.Section("server").Key("ROOT_URL").SetValue(form.AppURL)
cfg.Section("server").Key("APP_DATA_PATH").SetValue(setting.AppDataPath)
// TODO: hardcoded for now, make it configurable later
cfg.Section("discussion_server").Key("HOST").SetValue("localhost")
cfg.Section("discussion_server").Key("PORT").SetValue("8081")
if form.SSHPort == 0 {
cfg.Section("server").Key("DISABLE_SSH").SetValue("true")
} else {