You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
873 B
49 lines
873 B
package services
|
|
|
|
import (
|
|
"context"
|
|
"github.com/labstack/echo/v4"
|
|
"sorbet/internal/services/company"
|
|
"sorbet/internal/services/config"
|
|
"sorbet/internal/services/feature"
|
|
"sorbet/internal/services/resource"
|
|
"sorbet/internal/services/system"
|
|
"sorbet/pkg/app"
|
|
)
|
|
|
|
var applets []app.Applet
|
|
|
|
func Init() {
|
|
applets = []app.Applet{
|
|
&config.Service{},
|
|
&company.Service{},
|
|
&resource.Service{},
|
|
&feature.Service{},
|
|
&system.Service{},
|
|
}
|
|
}
|
|
|
|
func Start(ctx context.Context) error {
|
|
e := ctx.Value("echo_framework").(*echo.Echo)
|
|
for _, service := range applets {
|
|
err := service.Init(app.NewContext(ctx, e.Group("")))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
err = service.Start()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func Stop() error {
|
|
for _, service := range applets {
|
|
err := service.Stop()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|