cmd/ctrld: always pass config file on windows start mode

On windows, the SYSTEM user is used to run ctrld service. This user has
different environment with the user that run the `ctrld` binary via CLI.
That causes the mismatch issue in config file path, log path, or more
generally, everything that involve with home directory.

To circumvent this pain, just always passing the config path and the
original home dir in start mode. So `ctrld run` command can setup things
correctly.
This commit is contained in:
Cuong Manh Le
2023-01-12 08:58:29 +07:00
committed by Cuong Manh Le
parent 53306235dc
commit 8e164185b9
2 changed files with 15 additions and 5 deletions
+4
View File
@@ -22,6 +22,7 @@ var (
secondaryUpstream string
domains []string
logPath string
homedir string
cacheSize int
cfg ctrld.Config
verbose int
@@ -44,6 +45,9 @@ func normalizeLogFilePath(logFilePath string) string {
if logFilePath == "" || filepath.IsAbs(logFilePath) || service.Interactive() {
return logFilePath
}
if homedir != "" {
return filepath.Join(homedir, logFilePath)
}
dir, _ := os.UserHomeDir()
if dir == "" {
return logFilePath