-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
37 lines (31 loc) · 871 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
package main
import (
"fmt"
"github.com/RenatoSerra22/stop-loss/commsclients"
"github.com/RenatoSerra22/stop-loss/core"
"github.com/RenatoSerra22/stop-loss/exchangeclients"
"github.com/RenatoSerra22/stop-loss/handlers"
log "github.com/cihub/seelog"
"github.com/gorilla/mux"
"net/http"
"os"
)
func main() {
core.LoadEnvVars()
commsclients.Load()
exchangeclients.Load()
addr, _ := determineListenAddress()
commsclients.Telegram.Send(commsclients.TelegramUser, "Bot Started up!")
go core.CheckPrices()
go commsclients.Telegram.Start()
router := mux.NewRouter()
router.HandleFunc("/health", handlers.HealthEndpointHandler).Methods("GET")
log.Critical(http.ListenAndServe(addr, router))
}
func determineListenAddress() (string, error) {
port := os.Getenv("PORT")
if port == "" {
return "", fmt.Errorf("$PORT not set")
}
return ":" + port, nil
}