-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
48 lines (40 loc) · 966 Bytes
/
main.go
File metadata and controls
48 lines (40 loc) · 966 Bytes
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
package main
import (
"os"
"github.com/cschen13/spotitube/server"
"github.com/cschen13/spotitube/utils"
"github.com/go-redis/redis"
)
func main() {
hostname := os.Getenv("SPOTITUBE_HOST")
scheme := "https://"
devPort := getPort() // Development server hosting the React app
if hostname == "" {
hostname = "localhost"
scheme = "http://"
devPort = ":3000"
}
sessionSecret := os.Getenv("SPOTITUBE_SESSION_SECRET")
if sessionSecret == "" {
sessionSecret = utils.GenerateRandStr(64)
}
redisURL := os.Getenv("REDIS_URL")
redisAddress := ":6379"
redisPassword := ""
if redisURL != "" {
opt, err := redis.ParseURL(redisURL)
if err != nil {
panic(err)
}
redisAddress = opt.Addr
redisPassword = opt.Password
}
s := server.NewServer(scheme+hostname, getPort(), redisAddress, redisPassword, sessionSecret, 1, devPort)
s.Start()
}
func getPort() string {
if p := os.Getenv("PORT"); p != "" {
return ":" + p
}
return ":8080"
}