fmt.Fprintln(os.Stderr, "Gitea:", userMessage)
if len(logMessage) > 0 {
- if !setting.IsProd() {
+ if !setting.IsProd {
fmt.Fprintf(os.Stderr, logMessage+"\n", args...)
}
}
}
x.SetMapper(names.GonicMapper{})
- x.SetLogger(NewXORMLogger(!setting.IsProd()))
- x.ShowSQL(!setting.IsProd())
+ x.SetLogger(NewXORMLogger(!setting.IsProd))
+ x.ShowSQL(!setting.IsProd)
return syncTables()
}
if status == http.StatusInternalServerError {
log.ErrorWithSkip(1, "%s: %s", title, message)
- if setting.IsProd() && !(ctx.User != nil && ctx.User.IsAdmin) {
+ if setting.IsProd && !(ctx.User != nil && ctx.User.IsAdmin) {
message = ""
}
}
log.ErrorWithSkip(1, "InternalServerError: %v", err)
var message string
- if !setting.IsProd() || (ctx.User != nil && ctx.User.IsAdmin) {
+ if !setting.IsProd || (ctx.User != nil && ctx.User.IsAdmin) {
message = err.Error()
}
func (ctx *Context) notFoundInternal(title string, err error) {
if err != nil {
log.ErrorWithSkip(2, "%s: %v", title, err)
- if !setting.IsProd() {
+ if !setting.IsProd {
ctx.Data["ErrorMsg"] = err
}
}
func (ctx *Context) serverErrorInternal(title string, err error) {
if err != nil {
log.ErrorWithSkip(2, "%s: %v", title, err)
- if !setting.IsProd() {
+ if !setting.IsProd {
ctx.Data["ErrorMsg"] = err
}
}
"CurrentURL": setting.AppSubURL + req.URL.RequestURI(),
"PageStartTime": startTime,
"Link": link,
- "IsProd": setting.IsProd(),
+ "IsProd": setting.IsProd,
},
}
// PageData is passed by reference, and it will be rendered to `window.config.pageData` in `head.tmpl` for JavaScript modules
// AddCacheControlToHeader adds suitable cache-control headers to response
func AddCacheControlToHeader(h http.Header, d time.Duration) {
- if setting.IsProd() {
+ if setting.IsProd {
h.Set("Cache-Control", "private, max-age="+strconv.Itoa(int(d.Seconds())))
} else {
h.Set("Cache-Control", "no-store")
PIDFile = "/run/gitea.pid"
WritePIDFile bool
RunMode string
+ IsProd bool
RunUser string
IsWindows bool
HasRobotsTxt bool
InternalToken string // internal access token
)
-// IsProd if it's a production mode
-func IsProd() bool {
- return strings.EqualFold(RunMode, "prod")
-}
-
func getAppPath() (string, error) {
var appPath string
var err error
// Please don't use root as a bandaid to "fix" something that is broken, instead the broken thing should instead be fixed properly.
unsafeAllowRunAsRoot := Cfg.Section("").Key("I_AM_BEING_UNSAFE_RUNNING_AS_ROOT").MustBool(false)
RunMode = Cfg.Section("").Key("RUN_MODE").MustString("prod")
+ IsProd = strings.EqualFold(RunMode, "prod")
// Does not check run user when the install lock is off.
if InstallLock {
currentUser, match := IsRunUserMatchCurrentUser(RunUser)
Funcs: NewFuncMap(),
Asset: GetAsset,
AssetNames: GetAssetNames,
- IsDevelopment: !setting.IsProd(),
+ IsDevelopment: !setting.IsProd,
DisableHTTPErrorRendering: true,
})
}
if err := recover(); err != nil {
combinedErr := fmt.Sprintf("PANIC: %v\n%s", err, string(log.Stack(2)))
log.Error("%v", combinedErr)
- if setting.IsProd() {
+ if setting.IsProd {
http.Error(resp, http.StatusText(500), 500)
} else {
http.Error(resp, combinedErr, 500)
if err := recover(); err != nil {
combinedErr := fmt.Sprintf("PANIC: %v\n%s", err, string(log.Stack(2)))
log.Error(combinedErr)
- if setting.IsProd() {
+ if setting.IsProd {
http.Error(w, http.StatusText(500), 500)
} else {
http.Error(w, combinedErr, 500)
w.Header().Set(`X-Frame-Options`, setting.CORSConfig.XFrameOptions)
- if !setting.IsProd() {
+ if !setting.IsProd {
store["ErrorMsg"] = combinedErr
}
err = rnd.HTML(w, 500, "status/500", templates.BaseVars().Merge(store))
sessionStore := session.GetSession(req)
if sessionStore == nil {
- if setting.IsProd() {
+ if setting.IsProd {
http.Error(w, http.StatusText(500), 500)
} else {
http.Error(w, combinedErr, 500)
w.Header().Set(`X-Frame-Options`, setting.CORSConfig.XFrameOptions)
- if !setting.IsProd() {
+ if !setting.IsProd {
store["ErrorMsg"] = combinedErr
}
err = rnd.HTML(w, 500, "status/500", templates.BaseVars().Merge(store))
m.Post("/action/{action}", user.Action)
}, reqSignIn)
- if !setting.IsProd() {
+ if !setting.IsProd {
m.Get("/template/*", dev.TemplatePreview)
}
Funcs: templates.NewFuncMap(),
Asset: templates.GetAsset,
AssetNames: templates.GetAssetNames,
- IsDevelopment: !setting.IsProd(),
+ IsDevelopment: !setting.IsProd,
})
return nil
}