@@ -18,6 +18,7 @@ import (
1818 "github.com/webhookx-io/webhookx/config"
1919 "github.com/webhookx-io/webhookx/config/modules"
2020 "github.com/webhookx-io/webhookx/constants"
21+ "github.com/webhookx-io/webhookx/dashboard"
2122 "github.com/webhookx-io/webhookx/db"
2223 "github.com/webhookx-io/webhookx/db/dao"
2324 "github.com/webhookx-io/webhookx/db/migrator"
@@ -184,6 +185,11 @@ func (app *Application) initialize() error {
184185 return err
185186 }
186187
188+ // dashboard
189+ if err := app .initDashboard (& cfg .Dashboard ); err != nil {
190+ return err
191+ }
192+
187193 // gateway
188194 if err := app .initGateway (& cfg .Proxy , services , dispatcher , metrics ); err != nil {
189195 return err
@@ -287,6 +293,17 @@ func (app *Application) initAdmin(cfg *modules.AdminConfig, services *services.S
287293 return nil
288294}
289295
296+ func (app * Application ) initDashboard (cfg * modules.DashboardConfig ) error {
297+ if cfg .IsEnabled () {
298+ dashboard , err := dashboard .NewDashboard (* cfg )
299+ if err != nil {
300+ return err
301+ }
302+ app .registerService (dashboard )
303+ }
304+ return nil
305+ }
306+
290307func (app * Application ) initGateway (cfg * modules.ProxyConfig , services * services.Services , d * dispatcher.Dispatcher , metrics * metrics.Metrics ) error {
291308 if cfg .IsEnabled () {
292309 opts := proxy.Options {
@@ -507,6 +524,7 @@ func (app *Application) Start() error {
507524 fmt .Println ("- Version:" , utils .Colorize (webhookx .VERSION , utils .ColorDarkBlue , colored ))
508525 fmt .Println ("- Proxy URL:" , utils .Colorize (app .cfg .Proxy .URL (), utils .ColorDarkBlue , colored ))
509526 fmt .Println ("- Admin URL:" , utils .Colorize (app .cfg .Admin .URL (), utils .ColorDarkBlue , colored ))
527+ fmt .Println ("- Dashboard URL:" , utils .Colorize (app .cfg .Dashboard .URL (), utils .ColorDarkBlue , colored ))
510528 fmt .Println ("- Status URL:" , utils .Colorize (app .cfg .Status .URL (), utils .ColorDarkBlue , colored ))
511529 fmt .Println ("- Worker:" , utils .Colorize (app .cfg .Worker .Status (), utils .ColorDarkBlue , colored ))
512530 fmt .Println ()
@@ -553,6 +571,7 @@ func (app *Application) Start() error {
553571 app .getService ("eventbus" ),
554572 app .getService ("metrics" ),
555573 app .getService ("admin" ),
574+ app .getService ("dashboard" ),
556575 app .getService ("worker" ),
557576 app .getService ("proxy" ),
558577 app .getService ("status" ),
@@ -578,7 +597,7 @@ func (app *Application) stop(ctx context.Context) error {
578597 defer func () { _ = app .log .Sync () }()
579598
580599 var errs []error
581- errs = append (errs , stopServices (ctx , time .Second * 10 , app .getService ("proxy" ), app .getService ("admin" ), app .getService ("status" )))
600+ errs = append (errs , stopServices (ctx , time .Second * 10 , app .getService ("proxy" ), app .getService ("admin" ), app .getService ("dashboard" ), app . getService ( " status" )))
582601 errs = append (errs , stopServices (ctx , 0 , app .getService ("eventbus" )))
583602 errs = append (errs , stopServices (ctx , 0 , app .getService ("worker" )))
584603 errs = append (errs , stopServices (ctx , time .Second * 5 , app .getService ("metrics" ), app .getService ("tracing" )))
0 commit comments