mirror of
https://github.com/usual2970/certimate.git
synced 2025-10-04 21:44:54 +00:00
handle exit logic
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/usual2970/certimate/internal/notify"
|
||||
"github.com/usual2970/certimate/internal/repository"
|
||||
"github.com/usual2970/certimate/internal/rest"
|
||||
@@ -11,14 +13,26 @@ import (
|
||||
"github.com/pocketbase/pocketbase/apis"
|
||||
)
|
||||
|
||||
var (
|
||||
workflowSvc rest.WorkflowService
|
||||
workflowSvcOnce sync.Once
|
||||
)
|
||||
|
||||
func getWorkflowService() rest.WorkflowService {
|
||||
workflowSvcOnce.Do(func() {
|
||||
workflowRepo := repository.NewWorkflowRepository()
|
||||
workflowSvc = workflow.NewWorkflowService(workflowRepo)
|
||||
})
|
||||
return workflowSvc
|
||||
}
|
||||
|
||||
func Register(e *echo.Echo) {
|
||||
group := e.Group("/api", apis.RequireAdminAuth())
|
||||
|
||||
notifyRepo := repository.NewSettingsRepository()
|
||||
notifySvc := notify.NewNotifyService(notifyRepo)
|
||||
|
||||
workflowRepo := repository.NewWorkflowRepository()
|
||||
workflowSvc := workflow.NewWorkflowService(workflowRepo)
|
||||
workflowSvc := getWorkflowService()
|
||||
|
||||
statisticsRepo := repository.NewStatisticsRepository()
|
||||
statisticsSvc := statistics.NewStatisticsService(statisticsRepo)
|
||||
@@ -29,3 +43,7 @@ func Register(e *echo.Echo) {
|
||||
|
||||
rest.NewStatisticsHandler(group, statisticsSvc)
|
||||
}
|
||||
|
||||
func Unregister() {
|
||||
getWorkflowService().Stop()
|
||||
}
|
||||
|
Reference in New Issue
Block a user