-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
56 lines (45 loc) · 1.23 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"fmt"
"log"
"os"
//_ "net/http/pprof"
"github.com/Shelex/webhook-listener/api"
"github.com/Shelex/webhook-listener/app"
"github.com/joho/godotenv"
)
// @title webhook listener API
// @version 1.0
// @description webhook listener api
// @schemes https
// @host webhook-api.shelex.dev
// @BasePath /
// @contact.name API Support
// @contact.url http://www.swagger.io/support
// @contact.email ovr.shevtsov@gmail.com
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
func main() {
err := godotenv.Load()
if err != nil {
log.Printf("Error loading .env file: %s", err)
}
// download results for pprof profiler with "make prof"
// go func() {
// log.Println(http.ListenAndServe("localhost:6060", nil))
// }()
app, err := app.NewApp()
if err != nil {
log.Fatal(err)
}
api.RegisterControllers(app)
api.RegisterSwagger(app)
// clear expired items at 0 min every third hour
app.Cron.Schedule("0 */3 * * *", app.Repository.ClearExpired)
log.Println("Starting HTTP server")
host := os.Getenv("HOST")
port := os.Getenv("PORT")
if err := app.Router.Listen(fmt.Sprintf("%s:%s", host, port)); err != nil {
log.Printf("Could not start HTTP server %s:\n", err)
}
}