-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (33 loc) · 809 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
package main
import (
log "github.com/Sirupsen/logrus"
"github.com/gorilla/mux"
"github.com/hebestreit/spotify-headphone-party/party"
"github.com/hebestreit/spotify-headphone-party/redis"
"gopkg.in/boj/redistore.v1"
"net/http"
"os"
)
func init() {
log.SetFormatter(&log.JSONFormatter{})
log.SetOutput(os.Stdout)
logEnv, ok := os.LookupEnv("LOG_LEVEL")
if !ok {
logEnv = log.InfoLevel.String()
}
logLevel, _ := log.ParseLevel(logEnv)
log.SetLevel(logLevel)
}
func main() {
redisPool := redis.NewPool()
defer redisPool.Close()
store, err := redistore.NewRediStoreWithPool(redisPool, []byte(os.Getenv("SESSION_KEY")))
if err != nil {
panic(err)
}
defer store.Close()
r := mux.NewRouter()
server := party.NewServer(store)
go server.Listen(r)
http.ListenAndServe(":8090", r)
}