Make CustomPath, CustomConf and AppWorkPath configurable at build (#6631)
This commit is contained in:
parent
ccf4783980
commit
8d0d7bc28d
17 changed files with 184 additions and 193 deletions
|
@ -391,12 +391,12 @@ func getAppPath() (string, error) {
|
|||
}
|
||||
|
||||
func getWorkPath(appPath string) string {
|
||||
workPath := ""
|
||||
giteaWorkPath := os.Getenv("GITEA_WORK_DIR")
|
||||
workPath := AppWorkPath
|
||||
|
||||
if len(giteaWorkPath) > 0 {
|
||||
if giteaWorkPath, ok := os.LookupEnv("GITEA_WORK_DIR"); ok {
|
||||
workPath = giteaWorkPath
|
||||
} else {
|
||||
}
|
||||
if len(workPath) == 0 {
|
||||
i := strings.LastIndex(appPath, "/")
|
||||
if i == -1 {
|
||||
workPath = appPath
|
||||
|
@ -475,27 +475,40 @@ func CheckLFSVersion() {
|
|||
}
|
||||
}
|
||||
|
||||
// NewContext initializes configuration context.
|
||||
// NOTE: do not print any log except error.
|
||||
func NewContext() {
|
||||
Cfg = ini.Empty()
|
||||
|
||||
CustomPath = os.Getenv("GITEA_CUSTOM")
|
||||
// SetCustomPathAndConf will set CustomPath and CustomConf with reference to the
|
||||
// GITEA_CUSTOM environment variable and with provided overrides before stepping
|
||||
// back to the default
|
||||
func SetCustomPathAndConf(providedCustom, providedConf string) {
|
||||
if giteaCustom, ok := os.LookupEnv("GITEA_CUSTOM"); ok {
|
||||
CustomPath = giteaCustom
|
||||
}
|
||||
if len(providedCustom) != 0 {
|
||||
CustomPath = providedCustom
|
||||
}
|
||||
if len(CustomPath) == 0 {
|
||||
CustomPath = path.Join(AppWorkPath, "custom")
|
||||
} else if !filepath.IsAbs(CustomPath) {
|
||||
CustomPath = path.Join(AppWorkPath, CustomPath)
|
||||
}
|
||||
|
||||
if len(CustomPID) > 0 {
|
||||
createPIDFile(CustomPID)
|
||||
if len(providedConf) != 0 {
|
||||
CustomConf = providedConf
|
||||
}
|
||||
|
||||
if len(CustomConf) == 0 {
|
||||
CustomConf = path.Join(CustomPath, "conf/app.ini")
|
||||
} else if !filepath.IsAbs(CustomConf) {
|
||||
CustomConf = path.Join(CustomPath, CustomConf)
|
||||
}
|
||||
}
|
||||
|
||||
// NewContext initializes configuration context.
|
||||
// NOTE: do not print any log except error.
|
||||
func NewContext() {
|
||||
Cfg = ini.Empty()
|
||||
|
||||
if len(CustomPID) > 0 {
|
||||
createPIDFile(CustomPID)
|
||||
}
|
||||
|
||||
if com.IsFile(CustomConf) {
|
||||
if err := Cfg.Append(CustomConf); err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue