-
Notifications
You must be signed in to change notification settings - Fork 0
/
capybara.go
53 lines (43 loc) · 1.09 KB
/
capybara.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
51
52
53
package main
import (
"log"
"os"
"strconv"
"github.com/eventials/goawaysignals"
"github.com/hackerspaceblumenau/capybara/commands"
"github.com/hackerspaceblumenau/capybara/contracts"
"github.com/hackerspaceblumenau/capybara/slack"
"github.com/hackerspaceblumenau/capybara/storage/drivers"
"github.com/hackerspaceblumenau/capybara/ticker"
)
func main() {
slackToken := os.Getenv("SLACK_TOKEN")
if slackToken == "" {
log.Fatal("SLACK_TOKEN environment variable is empty")
}
commandsServerAddress := os.Getenv("SERVER_ADDR")
if commandsServerAddress == "" {
commandsServerAddress = "localhost"
}
commandsServerPort, _ := strconv.Atoi(os.Getenv("SERVER_PORT"))
if commandsServerPort == 0 {
commandsServerPort = 8080
}
slack.Setup(slackToken)
st := drivers.MemoryStorage{}
servers := []contracts.Server{
commands.NewServer(
st,
commands.RunOptions{
Address: commandsServerAddress,
Port: commandsServerPort,
}),
ticker.NewServer(st),
}
for _, srv := range servers {
go srv.Run()
}
log.Println("Starting...")
goawaysignals.Wait()
log.Println("Exiting...")
}