probe/config/path.go

71 lines
1.2 KiB
Go
Raw Normal View History

2018-04-18 14:56:13 +00:00
package config
import (
"fmt"
"os"
"path"
"path/filepath"
ocncc "git.loafle.net/overflow/commons-go/noauthprobe/constants"
ocpcc "git.loafle.net/overflow/commons-go/probe/constants"
)
var (
rootDir string
)
func init() {
exePath, err := os.Executable()
if err != nil {
panic(err)
}
binDir := filepath.Dir(exePath)
if "debug" == filepath.Base(exePath) {
rootDir = path.Join(binDir, "_build")
} else {
rootDir = filepath.Clean(fmt.Sprintf("%s/..", binDir))
}
}
func RootDir() string {
return rootDir
}
func BinDir() string {
return path.Join(RootDir(), ocpcc.PathBin)
}
func ConfigDir() string {
return path.Join(RootDir(), ocpcc.PathConfig)
}
func JREDir() string {
return path.Join(RootDir(), ocpcc.PathJRE)
}
func JavaBinPath() string {
return path.Join(JREDir(), "bin", "java")
}
func LogsDir() string {
return path.Join(RootDir(), ocpcc.PathLogs)
}
func PIDDir() string {
return path.Join(RootDir(), ocpcc.PathPID)
}
func ProbeConfigFilePath() string {
return path.Join(BinDir(), ocpcc.ConfigFileName)
}
func ProbeLoggingConfigFilePath() string {
return path.Join(BinDir(), ocpcc.LoggingConfigFileName)
}
func NoAuthProbeConfigFilePath() string {
return path.Join(BinDir(), ocncc.ConfigFileName)
}