about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--flake.nix1
-rw-r--r--internal/server/server.go11
-rwxr-xr-xjustfile2
3 files changed, 12 insertions, 2 deletions
diff --git a/flake.nix b/flake.nix
index 2ed262e..ad68d77 100644
--- a/flake.nix
+++ b/flake.nix
@@ -46,6 +46,7 @@
                 gomod2nix.packages.${system}.default
                 gci
                 hyperlink
+                systemfd
                 modd
                 nodePackages.vercel
                 netlify-cli
diff --git a/internal/server/server.go b/internal/server/server.go
index 4692965..71b9199 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -6,6 +6,7 @@ import (
 	"net"
 	"net/http"
 	"net/url"
+	"os"
 	"slices"
 	"time"
 
@@ -145,7 +146,15 @@ func New(runtimeConfig *Config) (*Server, error) {
 }
 
 func (s *Server) Start() error {
-	if err := s.ListenAndServe(); err != http.ErrServerClosed {
+	f := os.NewFile(uintptr(3), "")
+	l, err := net.FileListener(f)
+	if err != nil {
+		l, err = net.Listen("tcp", s.Addr)
+		if err != nil {
+			return errors.Wrap(err, "could not create listener")
+		}
+	}
+	if err := http.Serve(l, s.Handler); err != http.ErrServerClosed {
 		return errors.Wrap(err, "error creating/closing server")
 	}
 
diff --git a/justfile b/justfile
index 5e8df3d..304eb98 100755
--- a/justfile
+++ b/justfile
@@ -39,7 +39,7 @@ nix-build what:
 watch-server: (watch-flake "watchexec -r -i content -i templates go run ./cmd/server")
 
 dev:
-	modd
+	systemfd -s http::3000 modd
 
 docker-stream system=(arch() + "-linux"):
     @nix build --print-out-paths .#docker-stream-{{ system }} | sh