-
Notifications
You must be signed in to change notification settings - Fork 9
/
main.go
41 lines (34 loc) · 853 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
package main
import (
"fmt"
"net/http"
_ "net/http/pprof"
"os"
"cloud.google.com/go/profiler"
"github.com/mikeydub/go-gallery/emails"
"github.com/mikeydub/go-gallery/service/logger"
sentryutil "github.com/mikeydub/go-gallery/service/sentry"
"google.golang.org/appengine"
)
func main() {
defer sentryutil.RecoverAndRaise(nil)
cfg := profiler.Config{
Service: "emails",
ServiceVersion: "1.0.0",
MutexProfiling: true,
}
// Profiler initialization, best done as early as possible.
if err := profiler.Start(cfg); err != nil {
logger.For(nil).Warnf("failed to start cloud profiler due to error: %s\n", err)
}
emails.InitServer()
if appengine.IsAppEngine() {
appengine.Main()
} else {
port := "5500"
if it := os.Getenv("PORT"); it != "" {
port = it
}
http.ListenAndServe(fmt.Sprintf(":%s", port), nil)
}
}