Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions cmd/pho/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"os/signal"
"pho/internal/app"
"pho/internal/config"
"syscall"
"time"
)
Expand All @@ -14,18 +15,17 @@ func main() {
os.Exit(run())
}

// getTimeout returns the configured timeout from environment variable or default.
// getTimeout returns the configured timeout from config or environment variable.
func getTimeout() time.Duration {
const defaultTimeout = 60 * time.Second

if timeoutStr := os.Getenv("PHO_TIMEOUT"); timeoutStr != "" {
if timeout, err := time.ParseDuration(timeoutStr); err == nil {
return timeout
}
// If parsing fails, fall back to default
// Load config to get timeout
cfg, err := config.Load()
if err != nil {
// Fallback to default if config loading fails
const defaultTimeoutSeconds = 60
return defaultTimeoutSeconds * time.Second
}

return defaultTimeout
return cfg.GetTimeoutDuration()
}

func run() int {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.24
toolchain go1.24.3

require (
github.com/BurntSushi/toml v1.5.0
github.com/stretchr/testify v1.10.0
github.com/urfave/cli/v3 v3.3.8
go.mongodb.org/mongo-driver v1.17.4 // latest
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
Expand Down
Loading