-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
41 lines (36 loc) · 1.01 KB
/
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
package main /* import "s32x.com/gamedetect" */
import (
"log"
"math/rand"
"os"
"time"
"s32x.com/gamedetect/service"
)
func main() {
// Seed the random number generator
rand.Seed(time.Now().UTC().UnixNano())
// Generate a new service
s, err := service.NewService(
getenv("MODEL_PATH", "graph/output_graph.pb"), // The environment to run the server in
getenv("LABELS_PATH", "graph/output_labels.txt"), // The host the server is running on)
)
if err != nil {
log.Fatal(err)
}
defer s.Close()
s.Start(
getenv("PORT", "8080"), // The port the server will run on
getenv("TEST_PATH", "service/static/test"), // The host the server is running on)
)
}
// getenv attempts to retrieve and return a variable from the environment. If it
// fails it will either crash or failover to a passed default value
func getenv(key string, def ...string) string {
if v, ok := os.LookupEnv(key); ok {
return v
}
if len(def) == 0 {
log.Fatalf("%s not defined in environment", key)
}
return def[0]
}