|
|
@ -100,7 +100,7 @@ func newService() {
|
|
|
|
Service.EnableCacheAvatar = Cfg.MustBool("service", "ENABLE_CACHE_AVATAR", false)
|
|
|
|
Service.EnableCacheAvatar = Cfg.MustBool("service", "ENABLE_CACHE_AVATAR", false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func newLogService() {
|
|
|
|
func NewLogService() {
|
|
|
|
// Get and check log mode.
|
|
|
|
// Get and check log mode.
|
|
|
|
LogMode = Cfg.MustValue("log", "MODE", "console")
|
|
|
|
LogMode = Cfg.MustValue("log", "MODE", "console")
|
|
|
|
modeSec := "log." + LogMode
|
|
|
|
modeSec := "log." + LogMode
|
|
|
@ -125,7 +125,7 @@ func newLogService() {
|
|
|
|
logPath := Cfg.MustValue(modeSec, "FILE_NAME", "log/gogs.log")
|
|
|
|
logPath := Cfg.MustValue(modeSec, "FILE_NAME", "log/gogs.log")
|
|
|
|
os.MkdirAll(path.Dir(logPath), os.ModePerm)
|
|
|
|
os.MkdirAll(path.Dir(logPath), os.ModePerm)
|
|
|
|
LogConfig = fmt.Sprintf(
|
|
|
|
LogConfig = fmt.Sprintf(
|
|
|
|
`{"level":%s,"filename":%s,"rotate":%v,"maxlines":%d,"maxsize",%d,"daily":%v,"maxdays":%d}`, level,
|
|
|
|
`{"level":%s,"filename":"%s","rotate":%v,"maxlines":%d,"maxsize":%d,"daily":%v,"maxdays":%d}`, level,
|
|
|
|
logPath,
|
|
|
|
logPath,
|
|
|
|
Cfg.MustBool(modeSec, "LOG_ROTATE", true),
|
|
|
|
Cfg.MustBool(modeSec, "LOG_ROTATE", true),
|
|
|
|
Cfg.MustInt(modeSec, "MAX_LINES", 1000000),
|
|
|
|
Cfg.MustInt(modeSec, "MAX_LINES", 1000000),
|
|
|
@ -133,20 +133,20 @@ func newLogService() {
|
|
|
|
Cfg.MustBool(modeSec, "DAILY_ROTATE", true),
|
|
|
|
Cfg.MustBool(modeSec, "DAILY_ROTATE", true),
|
|
|
|
Cfg.MustInt(modeSec, "MAX_DAYS", 7))
|
|
|
|
Cfg.MustInt(modeSec, "MAX_DAYS", 7))
|
|
|
|
case "conn":
|
|
|
|
case "conn":
|
|
|
|
LogConfig = fmt.Sprintf(`{"level":%s,"reconnectOnMsg":%v,"reconnect":%v,"net":%s,"addr":%s}`, level,
|
|
|
|
LogConfig = fmt.Sprintf(`{"level":"%s","reconnectOnMsg":%v,"reconnect":%v,"net":"%s","addr":"%s"}`, level,
|
|
|
|
Cfg.MustBool(modeSec, "RECONNECT_ON_MSG", false),
|
|
|
|
Cfg.MustBool(modeSec, "RECONNECT_ON_MSG", false),
|
|
|
|
Cfg.MustBool(modeSec, "RECONNECT", false),
|
|
|
|
Cfg.MustBool(modeSec, "RECONNECT", false),
|
|
|
|
Cfg.MustValue(modeSec, "PROTOCOL", "tcp"),
|
|
|
|
Cfg.MustValue(modeSec, "PROTOCOL", "tcp"),
|
|
|
|
Cfg.MustValue(modeSec, "ADDR", ":7020"))
|
|
|
|
Cfg.MustValue(modeSec, "ADDR", ":7020"))
|
|
|
|
case "smtp":
|
|
|
|
case "smtp":
|
|
|
|
LogConfig = fmt.Sprintf(`{"level":%s,"username":%s,"password":%s,"host":%s,"sendTos":%s,"subject":%s}`, level,
|
|
|
|
LogConfig = fmt.Sprintf(`{"level":"%s","username":"%s","password":"%s","host":"%s","sendTos":"%s","subject":"%s"}`, level,
|
|
|
|
Cfg.MustValue(modeSec, "USER", "example@example.com"),
|
|
|
|
Cfg.MustValue(modeSec, "USER", "example@example.com"),
|
|
|
|
Cfg.MustValue(modeSec, "PASSWD", "******"),
|
|
|
|
Cfg.MustValue(modeSec, "PASSWD", "******"),
|
|
|
|
Cfg.MustValue(modeSec, "HOST", "127.0.0.1:25"),
|
|
|
|
Cfg.MustValue(modeSec, "HOST", "127.0.0.1:25"),
|
|
|
|
Cfg.MustValue(modeSec, "RECEIVERS", "[]"),
|
|
|
|
Cfg.MustValue(modeSec, "RECEIVERS", "[]"),
|
|
|
|
Cfg.MustValue(modeSec, "SUBJECT", "Diagnostic message from serve"))
|
|
|
|
Cfg.MustValue(modeSec, "SUBJECT", "Diagnostic message from serve"))
|
|
|
|
case "database":
|
|
|
|
case "database":
|
|
|
|
LogConfig = fmt.Sprintf(`{"level":%s,"driver":%s,"conn":%s}`, level,
|
|
|
|
LogConfig = fmt.Sprintf(`{"level":"%s","driver":"%s","conn":"%s"}`, level,
|
|
|
|
Cfg.MustValue(modeSec, "Driver"),
|
|
|
|
Cfg.MustValue(modeSec, "Driver"),
|
|
|
|
Cfg.MustValue(modeSec, "CONN"))
|
|
|
|
Cfg.MustValue(modeSec, "CONN"))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -259,11 +259,16 @@ func NewConfigContext() {
|
|
|
|
Cfg.BlockMode = false
|
|
|
|
Cfg.BlockMode = false
|
|
|
|
|
|
|
|
|
|
|
|
cfgPath = filepath.Join(workDir, "custom/conf/app.ini")
|
|
|
|
cfgPath = filepath.Join(workDir, "custom/conf/app.ini")
|
|
|
|
if com.IsFile(cfgPath) {
|
|
|
|
if !com.IsFile(cfgPath) {
|
|
|
|
if err = Cfg.AppendFiles(cfgPath); err != nil {
|
|
|
|
fmt.Println("Custom configuration not found(custom/conf/app.ini)\n" +
|
|
|
|
fmt.Printf("Cannot load config file '%s'\n", cfgPath)
|
|
|
|
"Please create it and make your own configuration!")
|
|
|
|
os.Exit(2)
|
|
|
|
os.Exit(2)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if err = Cfg.AppendFiles(cfgPath); err != nil {
|
|
|
|
|
|
|
|
fmt.Printf("Cannot load config file '%s'\n", cfgPath)
|
|
|
|
|
|
|
|
os.Exit(2)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AppName = Cfg.MustValue("", "APP_NAME", "Gogs: Go Git Service")
|
|
|
|
AppName = Cfg.MustValue("", "APP_NAME", "Gogs: Go Git Service")
|
|
|
@ -291,7 +296,7 @@ func NewConfigContext() {
|
|
|
|
|
|
|
|
|
|
|
|
func NewServices() {
|
|
|
|
func NewServices() {
|
|
|
|
newService()
|
|
|
|
newService()
|
|
|
|
newLogService()
|
|
|
|
NewLogService()
|
|
|
|
newCacheService()
|
|
|
|
newCacheService()
|
|
|
|
newSessionService()
|
|
|
|
newSessionService()
|
|
|
|
newMailService()
|
|
|
|
newMailService()
|
|
|
|