-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathorchestrator.go
49 lines (42 loc) · 1.11 KB
/
orchestrator.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
package cmd
import (
"net/http"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/thirdweb-dev/indexer/db"
"github.com/thirdweb-dev/indexer/internal/orchestrator"
"github.com/thirdweb-dev/indexer/internal/rpc"
)
var (
orchestratorCmd = &cobra.Command{
Use: "orchestrator",
Short: "TBD",
Long: "TBD",
Run: func(cmd *cobra.Command, args []string) {
RunOrchestrator(cmd, args)
},
}
)
func RunOrchestrator(cmd *cobra.Command, args []string) {
log.Info().Msg("Starting indexer")
rpc, err := rpc.Initialize()
if err != nil {
log.Fatal().Err(err).Msg("Failed to initialize RPC")
}
err = db.RunMigrations()
if err != nil {
log.Fatal().Err(err).Msg("Failed to run migrations")
}
orchestrator, err := orchestrator.NewOrchestrator(rpc)
if err != nil {
log.Fatal().Err(err).Msg("Failed to create orchestrator")
}
// Start Prometheus metrics server
log.Info().Msg("Starting Metrics Server on port 2112")
go func() {
http.Handle("/metrics", promhttp.Handler())
http.ListenAndServe(":2112", nil)
}()
orchestrator.Start()
}