|
|
@ -392,6 +392,7 @@ var ( |
|
|
|
Cfg *ini.File |
|
|
|
Cfg *ini.File |
|
|
|
CustomPath string // Custom directory path
|
|
|
|
CustomPath string // Custom directory path
|
|
|
|
CustomConf string |
|
|
|
CustomConf string |
|
|
|
|
|
|
|
CustomPID string |
|
|
|
ProdMode bool |
|
|
|
ProdMode bool |
|
|
|
RunUser string |
|
|
|
RunUser string |
|
|
|
IsWindows bool |
|
|
|
IsWindows bool |
|
|
@ -471,6 +472,22 @@ func IsRunUserMatchCurrentUser(runUser string) (string, bool) { |
|
|
|
return currentUser, runUser == currentUser |
|
|
|
return currentUser, runUser == currentUser |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func createPIDFile(pidPath string) { |
|
|
|
|
|
|
|
currentPid := os.Getpid() |
|
|
|
|
|
|
|
if err := os.MkdirAll(filepath.Dir(pidPath), os.ModePerm); err != nil { |
|
|
|
|
|
|
|
log.Fatal(4, "Can't create PID folder on %s", err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
file, err := os.Create(pidPath) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
log.Fatal(4, "Can't create PID file: %v", err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
defer file.Close() |
|
|
|
|
|
|
|
if _, err := file.WriteString(strconv.FormatInt(int64(currentPid), 10)); err != nil { |
|
|
|
|
|
|
|
log.Fatal(4, "Can'write PID information on %s", err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// NewContext initializes configuration context.
|
|
|
|
// NewContext initializes configuration context.
|
|
|
|
// NOTE: do not print any log except error.
|
|
|
|
// NOTE: do not print any log except error.
|
|
|
|
func NewContext() { |
|
|
|
func NewContext() { |
|
|
@ -498,6 +515,12 @@ please consider changing to GITEA_CUSTOM`) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(CustomPID) == 0 { |
|
|
|
|
|
|
|
CustomPID = CustomPath + "/run/app.pid" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
createPIDFile(CustomPID) |
|
|
|
|
|
|
|
|
|
|
|
if len(CustomConf) == 0 { |
|
|
|
if len(CustomConf) == 0 { |
|
|
|
CustomConf = CustomPath + "/conf/app.ini" |
|
|
|
CustomConf = CustomPath + "/conf/app.ini" |
|
|
|
} |
|
|
|
} |
|
|
|