-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
41 lines (36 loc) · 812 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"
"log"
"net/http"
"os"
"github.com/akrylysov/algnhsa"
"github.com/crhuber/polarbearblog/app"
"github.com/crhuber/polarbearblog/app/lib/timezone"
)
func init() {
// Verbose logging with file name and line number.
log.SetFlags(log.Lshortfile)
// Set the time zone.
timezone.Set()
}
func main() {
handler, err := app.Boot()
if err != nil {
log.Fatalln(err.Error())
}
// Start the web server.
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
// use lambda
if os.Getenv("AWS_LAMBDA_FUNCTION_NAME") != "" {
fmt.Println("Lambda server running")
opts := &algnhsa.Options{UseProxyPath: true}
algnhsa.ListenAndServe(handler, opts)
} else {
fmt.Println("Web server running on port:", port)
log.Fatalln(http.ListenAndServe(":"+port, handler))
}
}