Support nil user

This commit is contained in:
Berger Eugene 2023-09-08 20:10:48 +03:00
parent eaa05812bc
commit a149977b44
3 changed files with 18 additions and 4 deletions

View File

@ -25,7 +25,7 @@ swag:
~/go/bin/swag init --dir src --output src/docs --parseDependency --parseInternal --parseDepth 1 ~/go/bin/swag init --dir src --output src/docs --parseDependency --parseInternal --parseDepth 1
build: build:
go build -o bin/${NAME}${EXT} ${LD_FLAGS} ./src CGO_ENABLED=0 go build -o bin/${NAME}${EXT} ${LD_FLAGS} ./src
build-nix: build-nix:
nix build . nix build .

View File

@ -0,0 +1,9 @@
version: "0.5"
log_level: debug
log_length: 300
processes:
clientA:
command: "sleep 5 && touch ready"

View File

@ -34,7 +34,11 @@ func GetLogFilePath() string {
if found { if found {
return val return val
} }
return filepath.Join(os.TempDir(), fmt.Sprintf("process-compose-%s%s.log", mustUser(), mode())) userName := getUser()
if len(userName) != 0 {
userName = "-" + userName
}
return filepath.Join(os.TempDir(), fmt.Sprintf("process-compose%s%s.log", userName, mode()))
} }
func procCompHome() string { func procCompHome() string {
@ -58,10 +62,11 @@ func GetShortCutsPath() string {
return "" return ""
} }
func mustUser() string { func getUser() string {
usr, err := user.Current() usr, err := user.Current()
if err != nil { if err != nil {
log.Fatal().Err(err).Msg("Failed to retrieve user info") log.Warn().Err(err).Msg("Failed to retrieve user info.")
return ""
} }
return usr.Username return usr.Username
} }