-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
67 lines (57 loc) · 1.41 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
57
58
59
60
61
62
63
64
65
66
67
package main
import (
_ "breakfast/migrations"
"breakfast/services"
"breakfast/services/account"
"breakfast/services/apis"
"breakfast/services/auth"
"breakfast/services/events"
"breakfast/services/overlays"
"breakfast/services/pages"
"breakfast/services/saas"
"breakfast/services/viewers"
"breakfast/www"
"log"
"github.com/pocketbase/pocketbase"
"github.com/pocketbase/pocketbase/cmd"
"github.com/pocketbase/pocketbase/core"
"github.com/pocketbase/pocketbase/plugins/migratecmd"
"github.com/pocketbase/pocketbase/tools/cron"
)
func main() {
app := pocketbase.New()
scheduler := cron.New()
migratecmd.Register(app, app.RootCmd, migratecmd.Config{
Dir: "migrations",
})
// Setup App Global
services.RegisterApp(app)
// Setup Services
saas.RegisterService(app)
auth.RegisterService(app)
account.RegisterService(app)
apis.RegisterService(app)
viewers.RegisterService(app)
events.RegisterService(app)
overlays.RegisterService(app)
pages.RegisterService(app)
www.RegisterService(app)
// Setup jobs
auth.RegisterJobs(app, scheduler)
app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
scheduler.Start()
return nil
})
serveCmd := cmd.NewServeCommand(app, true)
err := app.Bootstrap()
if err != nil {
log.Fatal(err)
panic("failed to bootstrap pocketbase")
}
if err := serveCmd.Execute(); err != nil {
log.Fatal(err)
}
// if err := app.Start(); err != nil {
// log.Fatal(err)
// }
}