mirror of
https://github.com/aykhans/slash-e.git
synced 2026-09-24 23:06:48 +00:00
chore: implement runners
This commit is contained in:
+13
-4
@@ -17,6 +17,8 @@ import (
|
||||
"github.com/yourselfhosted/slash/server/profile"
|
||||
apiv1 "github.com/yourselfhosted/slash/server/route/api/v1"
|
||||
"github.com/yourselfhosted/slash/server/route/frontend"
|
||||
licensern "github.com/yourselfhosted/slash/server/runner/license"
|
||||
"github.com/yourselfhosted/slash/server/runner/version"
|
||||
"github.com/yourselfhosted/slash/server/service/license"
|
||||
"github.com/yourselfhosted/slash/store"
|
||||
)
|
||||
@@ -79,10 +81,7 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
|
||||
}
|
||||
|
||||
func (s *Server) Start(ctx context.Context) error {
|
||||
// Load subscription.
|
||||
if _, err := s.licenseService.LoadSubscription(ctx); err != nil {
|
||||
slog.Error("failed to load subscription", slog.Any("error", err))
|
||||
}
|
||||
s.StartBackgroundRunners(ctx)
|
||||
// Start gRPC server.
|
||||
listen, err := net.Listen("tcp", fmt.Sprintf(":%d", s.Profile.Port+1))
|
||||
if err != nil {
|
||||
@@ -119,6 +118,16 @@ func (s *Server) GetEcho() *echo.Echo {
|
||||
return s.e
|
||||
}
|
||||
|
||||
func (s *Server) StartBackgroundRunners(ctx context.Context) {
|
||||
licenseRunner := licensern.NewRunner(s.Store, s.licenseService)
|
||||
licenseRunner.RunOnce(ctx)
|
||||
versionRunner := version.NewRunner(s.Store, s.Profile)
|
||||
versionRunner.RunOnce(ctx)
|
||||
|
||||
go licenseRunner.Run(ctx)
|
||||
go versionRunner.Run(ctx)
|
||||
}
|
||||
|
||||
func (s *Server) getSecretSession(ctx context.Context) (string, error) {
|
||||
workspaceGeneralSetting, err := s.Store.GetWorkspaceGeneralSetting(ctx)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user