-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
50 lines (40 loc) · 998 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"log"
"os"
"github.com/joho/godotenv"
"github.com/kelseyhightower/envconfig"
"github.com/tinrab/graphql-realtime-chat/server"
)
type config struct {
RedisURL string `envconfig:"REDIS_URL"`
}
func main() {
// Load .env file if it exists
if err := godotenv.Load(); err != nil {
log.Printf("No .env file found")
}
var cfg config
err := envconfig.Process("", &cfg)
if err != nil {
log.Fatal(err)
}
redisURL := os.Getenv("REDIS_URL")
if redisURL == "" {
redisURL = "redis://localhost:6379"
}
// Debug environment variables
log.Printf("[DEBUG] Environment variables:")
log.Printf("GitHub Client ID: %s", os.Getenv("GITHUB_CLIENT_ID"))
log.Printf("GitHub Client Secret length: %d", len(os.Getenv("GITHUB_CLIENT_SECRET")))
log.Printf("Redis URL: %s", redisURL)
s, err := server.NewServer(redisURL)
if err != nil {
log.Fatal(err)
}
log.Printf("[DEBUG] Server created successfully")
err = s.Serve(8080)
if err != nil {
log.Fatal(err)
}
}