Skip to content

Commit

Permalink
Support nil user
Browse files Browse the repository at this point in the history
  • Loading branch information
F1bonacc1 committed Sep 17, 2023
1 parent eaa0581 commit a149977
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ swag:
~/go/bin/swag init --dir src --output src/docs --parseDependency --parseInternal --parseDepth 1

build:
go build -o bin/${NAME}${EXT} ${LD_FLAGS} ./src
CGO_ENABLED=0 go build -o bin/${NAME}${EXT} ${LD_FLAGS} ./src

build-nix:
nix build .
Expand Down
9 changes: 9 additions & 0 deletions issues/issue_84/process-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: "0.5"
log_level: debug
log_length: 300

processes:
clientA:
command: "sleep 5 && touch ready"


11 changes: 8 additions & 3 deletions src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ func GetLogFilePath() string {
if found {
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 {
Expand All @@ -58,10 +62,11 @@ func GetShortCutsPath() string {
return ""
}

func mustUser() string {
func getUser() string {
usr, err := user.Current()
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
}
Expand Down

0 comments on commit a149977

Please sign in to comment.