Skip to content

Commit

Permalink
Merge pull request #14 from amigus/fixes
Browse files Browse the repository at this point in the history
Logic and output fixes
  • Loading branch information
amigus authored Dec 20, 2024
2 parents 8a937e5 + 1a6e8bc commit 421b4ae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion host_dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func createReservationFile(input reservation, c *gin.Context, hostDir string, ov
return
}

content := fmt.Sprintf("%s", mac.ToColonDelimitedString())
content := mac.ToColonDelimitedString()

if len(input.Tags) > 0 {
content += "," + strings.Join(prefixTags(input.Tags), ",")
Expand Down
12 changes: 4 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,23 +205,19 @@ Setting -T 0 disables token checking entirely.
fmt.Println("token checking is disabled")
}

if verbose {
fmt.Printf("writing pid file: %s\n", pidFilePath)
}
// Start the child process in the background
pid := RunDaemon(pidFilePath, userFlag, groupFlag, envVars, extraFiles)

if verbose {
fmt.Printf("started a daemon with PID: %d; exiting with status 0\n", pid)
fmt.Printf("wrote pid file: %s\nstarted a daemon with PID: %d\nexiting with status 0\n", pidFilePath, pid)
}

// Exit the parent process having successfully started the child process
os.Exit(0)
} else {
// Open the database using the sqlite3 package
db, err := sql.Open("sqlite3", databaseFilePath)
if err != nil {
fmt.Fprintf(gin.DefaultErrorWriter, "unable to open database %s: %v",
fmt.Fprintf(os.Stderr, "unable to open database %s: %v",
databaseFilePath, err)
os.Exit(1)
}
Expand Down Expand Up @@ -254,11 +250,11 @@ Setting -T 0 disables token checking entirely.
go func() {
<-sigs
if err := os.Remove(pidFilePath); err != nil {
fmt.Fprintf(gin.DefaultErrorWriter, "unable to remove pid file: %v\n", err)
fmt.Fprintf(os.Stderr, "unable to remove pid file: %v\n", err)
}
if maxTokens > 0 {
if err := os.Remove(unixSocketPath); err != nil {
fmt.Fprintf(gin.DefaultErrorWriter, "unable to remove unix socket: %v\n", err)
fmt.Fprintf(os.Stderr, "unable to remove unix socket: %v\n", err)
}
}
os.Exit(1)
Expand Down

0 comments on commit 421b4ae

Please sign in to comment.