Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(): modify default log path #177

Merged
merged 1 commit into from
Aug 9, 2024
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
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