aboutsummaryrefslogtreecommitdiff
path: root/modules/setting
diff options
context:
space:
mode:
Diffstat (limited to 'modules/setting')
-rw-r--r--modules/setting/setting.go33
1 files changed, 24 insertions, 9 deletions
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index 6a205921..52dca3f0 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -68,8 +68,11 @@ var (
ReverseProxyAuthUser string
// Webhook settings.
- WebhookTaskInterval int
- WebhookDeliverTimeout int
+ Webhook struct {
+ TaskInterval int
+ DeliverTimeout int
+ SkipTLSVerify bool
+ }
// Repository settings.
RepoRootPath string
@@ -125,6 +128,7 @@ var (
Cfg *ini.File
ConfRootPath string
CustomPath string // Custom directory path.
+ CustomConf string
ProdMode bool
RunUser string
IsWindows bool
@@ -173,13 +177,16 @@ func NewConfigContext() {
CustomPath = path.Join(workDir, "custom")
}
- cfgPath := path.Join(CustomPath, "conf/app.ini")
- if com.IsFile(cfgPath) {
- if err = Cfg.Append(cfgPath); err != nil {
- log.Fatal(4, "Fail to load custom 'conf/app.ini': %v", err)
+ if len(CustomConf) == 0 {
+ CustomConf = path.Join(CustomPath, "conf/app.ini")
+ }
+
+ if com.IsFile(CustomConf) {
+ if err = Cfg.Append(CustomConf); err != nil {
+ log.Fatal(4, "Fail to load custom conf '%s': %v", CustomConf, err)
}
} else {
- log.Warn("No custom 'conf/app.ini' found, ignore this if you're running first time")
+ log.Warn("Custom config (%s) not found, ignore this if you're running first time", CustomConf)
}
Cfg.NameMapper = ini.AllCapsUnderscore
@@ -234,6 +241,9 @@ func NewConfigContext() {
sec = Cfg.Section("attachment")
AttachmentPath = sec.Key("PATH").MustString("data/attachments")
+ if !filepath.IsAbs(AttachmentPath) {
+ AttachmentPath = path.Join(workDir, AttachmentPath)
+ }
AttachmentAllowedTypes = sec.Key("ALLOWED_TYPES").MustString("image/jpeg|image/png")
AttachmentMaxSize = sec.Key("MAX_SIZE").MustInt64(32)
AttachmentMaxFiles = sec.Key("MAX_FILES").MustInt(10)
@@ -291,6 +301,9 @@ func NewConfigContext() {
sec = Cfg.Section("picture")
PictureService = sec.Key("SERVICE").In("server", []string{"server"})
AvatarUploadPath = sec.Key("AVATAR_UPLOAD_PATH").MustString("data/avatars")
+ if !filepath.IsAbs(AvatarUploadPath) {
+ AvatarUploadPath = path.Join(workDir, AvatarUploadPath)
+ }
os.MkdirAll(AvatarUploadPath, os.ModePerm)
switch sec.Key("GRAVATAR_SOURCE").MustString("gravatar") {
case "duoshuo":
@@ -504,8 +517,10 @@ func newNotifyMailService() {
}
func newWebhookService() {
- WebhookTaskInterval = Cfg.Section("webhook").Key("TASK_INTERVAL").MustInt(1)
- WebhookDeliverTimeout = Cfg.Section("webhook").Key("DELIVER_TIMEOUT").MustInt(5)
+ sec := Cfg.Section("webhook")
+ Webhook.TaskInterval = sec.Key("TASK_INTERVAL").MustInt(1)
+ Webhook.DeliverTimeout = sec.Key("DELIVER_TIMEOUT").MustInt(5)
+ Webhook.SkipTLSVerify = sec.Key("SKIP_TLS_VERIFY").MustBool()
}
func NewServices() {