Skip to content

Commit

Permalink
chore(): modify default log path (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunshinexcode authored Aug 9, 2024
1 parent 8ab71d3 commit 8e335e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# ------------------------------

# Log path
LOG_PATH=/tmp
LOG_PATH=/tmp/astra
# Graph designer server port
GRAPH_DESIGNER_SERVER_PORT=49483
# Server port
Expand Down
11 changes: 10 additions & 1 deletion server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ func main() {
slog.Warn("load .env file failed", "err", err)
}

// Check if the directory exists
logPath := os.Getenv("LOG_PATH")
if _, err := os.Stat(logPath); os.IsNotExist(err) {
if err := os.MkdirAll(logPath, os.ModePerm); err != nil {
slog.Error("create log directory failed", "err", err)
os.Exit(1)
}
}

// Check environment
agoraAppId := os.Getenv("AGORA_APP_ID")
if len(agoraAppId) != 32 {
Expand Down Expand Up @@ -49,7 +58,7 @@ func main() {
httpServerConfig := &internal.HttpServerConfig{
AppId: agoraAppId,
AppCertificate: os.Getenv("AGORA_APP_CERTIFICATE"),
LogPath: os.Getenv("LOG_PATH"),
LogPath: logPath,
Port: os.Getenv("SERVER_PORT"),
WorkersMax: workersMax,
WorkerQuitTimeoutSeconds: workerQuitTimeoutSeconds,
Expand Down

0 comments on commit 8e335e0

Please sign in to comment.