Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ to interact and monitor the Scroll Application`,
snapshotService := snapshotServices.NewSnapshotService()
coldStarter := services.NewColdStarter(portService, queueManager, snapshotService, scrollService.GetDir())

uiService := services.NewUiService(scrollService)
uiDevService := services.NewUiDevService()

scrollHandler := handler.NewScrollHandler(scrollService, pluginManager, processLauncher, queueManager, processManager)
processHandler := handler.NewProcessHandler(processManager)
scrollLogHandler := handler.NewScrollLogHandler(scrollService, logManager, processManager)
Expand All @@ -135,6 +138,8 @@ to interact and monitor the Scroll Application`,
portHandler := handler.NewPortHandler(portService)
healthHandler := handler.NewHealthHandler(portService, maxStartupHealthCheckTimeout, snapshotService)
coldstarterHandler := handler.NewColdstarterHandler(coldStarter)
uiHandler := handler.NewUiHandler(uiService)
uiDevHandler := handler.NewUiDevHandler(uiDevService, scrollService)

var annotationHandler *handler.AnnotationHandler = nil

Expand All @@ -147,7 +152,7 @@ to interact and monitor the Scroll Application`,
signalHandler := signals.NewSignalHandler(ctx, queueManager, processManager, nil, shutdownWait)
daemonHander := handler.NewDaemonHandler(signalHandler)

s := web.NewServer(jwksUrl, scrollHandler, scrollLogHandler, scrollMetricHandler, annotationHandler, processHandler, queueHandler, websocketHandler, portHandler, healthHandler, coldstarterHandler, daemonHander, authorizer, cwd)
s := web.NewServer(jwksUrl, scrollHandler, scrollLogHandler, scrollMetricHandler, annotationHandler, processHandler, queueHandler, websocketHandler, portHandler, healthHandler, coldstarterHandler, daemonHander, authorizer, uiHandler, uiDevHandler, cwd, scrollService.GetDir())

a := s.Initialize()

Expand Down
34 changes: 30 additions & 4 deletions cmd/server/web/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/gofiber/fiber/v2/middleware/cors"
jwtware "github.com/gofiber/jwt/v3"
"github.com/highcard-dev/daemon/cmd/server/web/middlewares"

constants "github.com/highcard-dev/daemon/internal"
"github.com/highcard-dev/daemon/internal/core/ports"
"github.com/highcard-dev/daemon/internal/utils/logger"
Expand All @@ -36,8 +37,11 @@ type Server struct {
portHandler ports.PortHandlerInterface
healthHandler ports.HealthHandlerInterface
coldstarterHandler ports.ColdstarterHandlerInterface
daemonHander ports.SignalHandlerInterface
daemonHandler ports.SignalHandlerInterface
uiHandler ports.UiHandlerInterface
uiDevHandler ports.UiDevHandlerInterface
webdavPath string
scrollPath string
}

func NewServer(
Expand All @@ -52,9 +56,12 @@ func NewServer(
portHandler ports.PortHandlerInterface,
healthHandler ports.HealthHandlerInterface,
coldstarterHandler ports.ColdstarterHandlerInterface,
daemonHander ports.SignalHandlerInterface,
daemonHandler ports.SignalHandlerInterface,
authorizerService ports.AuthorizerServiceInterface,
uiHandler ports.UiHandlerInterface,
uiDevHandler ports.UiDevHandlerInterface,
webdavPath string,
scrollPath string,
) *Server {
server := &Server{
corsMiddleware: cors.New(cors.Config{
Expand All @@ -76,7 +83,10 @@ func NewServer(
healthHandler: healthHandler,
coldstarterHandler: coldstarterHandler,
webdavPath: webdavPath,
daemonHander: daemonHander,
scrollPath: scrollPath,
daemonHandler: daemonHandler,
uiHandler: uiHandler,
uiDevHandler: uiDevHandler,
}

if jwlsUrl != "" {
Expand Down Expand Up @@ -121,9 +131,13 @@ func (s *Server) SetAPI(app *fiber.App) *fiber.App {
apiRoutes := v1.Group("/")
webdavRoutes := app.Group("/webdav")

privateUiRoutes := app.Use(s.corsMiddleware)
publicUiRoutes := app.Use(s.corsMiddleware)

if s.jwtMiddleware != nil {
apiRoutes.Use(s.jwtMiddleware, s.injectUserMiddleware)
webdavRoutes.Use(s.jwtMiddleware, s.injectUserMiddleware)
privateUiRoutes.Use(s.jwtMiddleware, s.injectUserMiddleware)
}

wsRoutes.Use(s.tokenAuthenticationMiddleware)
Expand Down Expand Up @@ -157,7 +171,12 @@ func (s *Server) SetAPI(app *fiber.App) *fiber.App {

apiRoutes.Get("/health", s.healthHandler.Health).Name("health-authenticated")

apiRoutes.Post("/daemon/stop", s.daemonHander.Stop).Name("daemon.stop")
apiRoutes.Post("/daemon/stop", s.daemonHandler.Stop).Name("daemon.stop")

//UI Dev Group
apiRoutes.Post("/dev/enable", s.uiDevHandler.Enable).Name("dev.enable")
apiRoutes.Post("/dev/disable", s.uiDevHandler.Disable).Name("dev.disable")
apiRoutes.Get("/dev/status", s.uiDevHandler.Status).Name("dev.status")

// Create the WebDAV handler
webdavHandler := &webdav.Handler{
Expand All @@ -169,9 +188,16 @@ func (s *Server) SetAPI(app *fiber.App) *fiber.App {
webdavRoutes.Use("*", adaptor.HTTPHandler(webdavHandler))

wsRoutes.Get("/serve/:console", websocket.New(s.websocketHandler.HandleProcess)).Name("ws.serve")
wsRoutes.Get("/dev/notify", websocket.New(s.uiDevHandler.NotifyChange)).Name("ws.dev.notify")

apiRoutes.Get("/ports", s.portHandler.GetPorts).Name("ports.list")

publicUiRoutes.Get("/public/index", s.uiHandler.PublicIndex).Name("ui.public_index")
publicUiRoutes.Static("/public", s.scrollPath+"/public").Name("ui.public")

privateUiRoutes.Get("/private/index", s.uiHandler.PrivateIndex).Name("ui.private_index")
privateUiRoutes.Static("/private", s.scrollPath+"/private").Name("ui.private")

if s.annotationHandler != nil {
app.Get("/annotations", s.annotationHandler.Annotations).Name("annotations.list")
}
Expand Down
58 changes: 15 additions & 43 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/highcard-dev/daemon

go 1.23.0
go 1.24.0

toolchain go1.24.7

require (
github.com/Masterminds/semver/v3 v3.2.1
Expand All @@ -24,12 +26,12 @@ require (
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/andybalholm/brotli v1.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/fasthttp/websocket v1.5.8 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fsnotify/fsnotify v1.7.0
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
Expand All @@ -45,10 +47,10 @@ require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/joho/godotenv v1.5.1
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13
github.com/mattn/go-colorable v0.1.14
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
Expand All @@ -69,47 +71,28 @@ require (
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.52.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
github.com/valyala/fasthttp v1.65.0 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/net v0.33.0
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/tools v0.28.0 // indirect
golang.org/x/crypto v0.42.0 // indirect
golang.org/x/net v0.44.0
golang.org/x/sync v0.17.0 // indirect
golang.org/x/sys v0.36.0 // indirect
golang.org/x/text v0.29.0 // indirect
golang.org/x/tools v0.36.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/grpc v1.65.0
google.golang.org/protobuf v1.34.2
gopkg.in/ini.v1 v1.67.0 // indirect
)

require (
cloud.google.com/go v0.112.1 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/iam v1.1.6 // indirect
cloud.google.com/go/storage v1.38.0 // indirect
github.com/aws/aws-sdk-go v1.44.122 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-ini/ini v1.67.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/goccy/go-json v0.10.4 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.3 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
github.com/minio/md5-simd v1.1.2 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
Expand All @@ -119,20 +102,9 @@ require (
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
github.com/stretchr/testify v1.10.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
golang.org/x/exp v0.0.0-20241210194714-1829a127f884 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.171.0 // indirect
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
)

require (
Expand Down
Loading