-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
39 lines (34 loc) · 865 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
package main
import (
"flag"
"fmt"
"log"
"os"
"os/signal"
"syscall"
"github.com/Scalingo/sample-influxdb/config"
"github.com/Scalingo/sample-influxdb/utils"
"github.com/Scalingo/sample-influxdb/webserver"
"github.com/Scalingo/sample-influxdb/worker"
)
func main() {
flagIsWorker := flag.Bool("worker", false, "is a worker")
flag.Parse()
var closer utils.Closer
if *flagIsWorker {
if config.E["TWITTER_CONSUMER_KEY"] == "" || config.E["TWITTER_CONSUMER_SECRET"] == "" ||
config.E["TWITTER_ACCESS_TOKEN"] == "" || config.E["TWITTER_ACCESS_SECRET"] == "" {
log.Fatal("Missing Twitter OAuth1 information")
}
closer = worker.Start()
} else {
closer = webserver.Start()
}
sigs := make(chan os.Signal)
signal.Notify(sigs, syscall.SIGTERM)
<-sigs
fmt.Println("SIGTERM, time to shutdown")
if closer != nil {
_ = closer.Close()
}
}