aboutsummaryrefslogtreecommitdiff
path: root/modules/setting/setting.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/setting/setting.go')
-rw-r--r--modules/setting/setting.go37
1 files changed, 21 insertions, 16 deletions
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index 32284b42..fd07c17f 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -67,11 +67,16 @@ var (
CookieRememberName string
ReverseProxyAuthUser string
+ // Database settings.
+ UseSQLite3 bool
+ UseMySQL bool
+ UsePostgreSQL bool
+
// Webhook settings.
Webhook struct {
- TaskInterval int
- DeliverTimeout int
- AllowInsecureCertification bool
+ TaskInterval int
+ DeliverTimeout int
+ SkipTLSVerify bool
}
// Repository settings.
@@ -240,7 +245,10 @@ func NewConfigContext() {
ReverseProxyAuthUser = sec.Key("REVERSE_PROXY_AUTHENTICATION_USER").MustString("X-WEBAUTH-USER")
sec = Cfg.Section("attachment")
- AttachmentPath = path.Join(workDir, sec.Key("PATH").MustString("data/attachments"))
+ 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)
@@ -264,10 +272,6 @@ func NewConfigContext() {
"StampNano": time.StampNano,
}[Cfg.Section("time").Key("FORMAT").MustString("RFC1123")]
- if err = os.MkdirAll(AttachmentPath, os.ModePerm); err != nil {
- log.Fatal(4, "Could not create directory %s: %s", AttachmentPath, err)
- }
-
RunUser = Cfg.Section("").Key("RUN_USER").String()
curUser := os.Getenv("USER")
if len(curUser) == 0 {
@@ -290,15 +294,14 @@ func NewConfigContext() {
} else {
RepoRootPath = filepath.Clean(RepoRootPath)
}
- if err = os.MkdirAll(RepoRootPath, os.ModePerm); err != nil {
- log.Fatal(4, "Fail to create repository root path(%s): %v", RepoRootPath, err)
- }
ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash")
sec = Cfg.Section("picture")
PictureService = sec.Key("SERVICE").In("server", []string{"server"})
- AvatarUploadPath = path.Join(workDir, sec.Key("AVATAR_UPLOAD_PATH").MustString("data/avatars"))
- os.MkdirAll(AvatarUploadPath, os.ModePerm)
+ AvatarUploadPath = sec.Key("AVATAR_UPLOAD_PATH").MustString("data/avatars")
+ if !filepath.IsAbs(AvatarUploadPath) {
+ AvatarUploadPath = path.Join(workDir, AvatarUploadPath)
+ }
switch sec.Key("GRAVATAR_SOURCE").MustString("gravatar") {
case "duoshuo":
GravatarSource = "http://gravatar.duoshuo.com/avatar/"
@@ -363,9 +366,11 @@ func newLogService() {
log.Fatal(4, "Unknown log mode: %s", mode)
}
+ validLevels := []string{"Trace", "Debug", "Info", "Warn", "Error", "Critical"}
// Log level.
- levelName := Cfg.Section("log."+mode).Key("LEVEL").In("Trace",
- []string{"Trace", "Debug", "Info", "Warn", "Error", "Critical"})
+ levelName := Cfg.Section("log."+mode).Key("LEVEL").In(
+ Cfg.Section("log").Key("LEVEL").In("Trace", validLevels),
+ validLevels)
level, ok := logLevels[levelName]
if !ok {
log.Fatal(4, "Unknown log level: %s", levelName)
@@ -519,7 +524,7 @@ func newWebhookService() {
sec := Cfg.Section("webhook")
Webhook.TaskInterval = sec.Key("TASK_INTERVAL").MustInt(1)
Webhook.DeliverTimeout = sec.Key("DELIVER_TIMEOUT").MustInt(5)
- Webhook.AllowInsecureCertification = sec.Key("ALLOW_INSECURE_CERTIFICATION").MustBool()
+ Webhook.SkipTLSVerify = sec.Key("SKIP_TLS_VERIFY").MustBool()
}
func NewServices() {