lightsystemdarkgreen
@ 261119.3

261118.11 65ad42caa120f8b29aceff528e148e26d1fdd1a2 The default address's server stays up, so the web address answers

The web address answered only while a tree was served. A forge link on a page leads there, and with no server it was a dead end.

The server on the default address now stays up when its last tree goes. --restart, which the login units run, starts one there with no tree when none runs, and replaces one with no tree by the current binary, as it does a server with trees. A tree joins it as any server. Kill server and --kill still stop it; the next login brings it back.

The web address now starts before the first tree is adopted. The tree's warm-up read the cache's paths while startWeb set them, a race the new tests on the default address showed.

reading declarations

README.md

@@ -35,7 +35,7 @@ www-public -V | --version  Run `www` in a directory. It prints the tree's URL and opens it with `xdg-open`, a tab in your default browser. To open it another way, set `WWW_OPEN`, eg `WWW_OPEN='brave-browser --app=%s'` for a window of its own; [options](doc/options.md) has more. -It also writes a lockfile named after the endpoint, eg `127.31.1.1-8080.lock`. Delete the lockfile to stop serving the tree. Trees on one address share one server, which exits when its last lock is gone.+It also writes a lockfile named after the endpoint, eg `127.31.1.1-8080.lock`. Delete the lockfile to stop serving the tree. Trees on one address share one server, which exits when its last lock is gone. The server on your default address stays up, since it also serves [online repos](doc/online-repos.md).  ``` www                         serve this directory and open it

args.go

@@ -87,7 +87,9 @@ Options:                         and a restart keeps it   --restart             replace every server this binary started with one                         running it now, serving the same trees, and start-                        one for its persistent trees that have none; with an+                        one for its persistent trees that have none, and+                        one on the default address with no tree, for online+                        repos; with an                         address from -a or --share, only the server there,                         whichever binary runs it; with DIR, serve it too and                         open it unless a page of it was open

doc/online-repos.md

@@ -1,6 +1,6 @@ # Online repos -The server on your default address also listens on the address after it, 127.31.N.2, on the same port. There a URL names a repo on a forge by its host and path, eg `http://127.31.1.2/github.com/junegunn/fzf/README.md`. The first visit fetches the repo into a cache. From then on www serves it as it serves a checkout: docs, code, listings, search and history.+The server on your default address also listens on the address after it, 127.31.N.2, on the same port. That server stays up with no tree, and `www --restart`, which the login unit runs, starts it, so the web address answers at all times. There a URL names a repo on a forge by its host and path, eg `http://127.31.1.2/github.com/junegunn/fzf/README.md`. The first visit fetches the repo into a cache. From then on www serves it as it serves a checkout: docs, code, listings, search and history.  Home and the web never collide, since each has an address of its own. 

doc/servers.md

@@ -12,7 +12,7 @@ Trees on one address share one server. The first `www` starts it in the backgrou  When something other than your www on that address holds the port, `www` fails at once with `E98` and names the listeners there. -The server exits when its last lock is gone. SIGTERM stops it at once and removes every lock but a persistent `.LOCK`, as does the Kill server button on the index at `/`.+The server exits when its last lock is gone, except on your default address. That server also serves the web address, which answers at all times, so it stays up with no tree. SIGTERM stops any server at once and removes every lock but a persistent `.LOCK`, as do the Kill server button on the index at `/` and `www --kill`.  Delete lock and Kill server answer 410 Gone. The page shows the code and "Gone" on the line below it, then names each tree stopped, its lock removed or kept, and whether the server serves on. @@ -24,6 +24,8 @@ It moves only the servers its own binary started, so the package and a build fro  A binary without the capability for port 80, such as the one from `make install`, leaves a port-80 server on its old binary and says so. +`www --restart` also starts a server on its binary's default address when none runs there, with no tree, so the web address answers. A server there with no tree is replaced by the current binary, as one with trees is. `-a` or `--share` limits it to that address and starts nothing else.+ ## The index  The index at `/` reads the same on every server. It lists each running server in the order of their addresses, with the address and the binary it runs. Each server's trees follow, with the lock's path on hover.@@ -52,7 +54,7 @@ Deleting the `.LOCK`, or Delete lock on the tree's pages, ends the tree for good  ## Systemd units -A systemd user unit runs `www --restart` at login. Both ship disabled. They serve from login to logout, and linger stays off.+A systemd user unit runs `www --restart` at login, which also starts the server on the default address with no tree. Both ship disabled. They serve from login to logout, and linger stays off.  - The package puts `www.service` in `/usr/lib/systemd/user/`. Enable it with `systemctl --user enable www`. - `make install` puts `www-dev.service` in `~/.config/systemd/user/`. Enable it with `systemctl --user enable www-dev`.

index_test.go

@@ -19,7 +19,7 @@ func TestIndexDeleteReturns(t *testing.T) { 	tr.prefix, tr.label = "/notes/", "~/notes" 	addTree(t, s, filepath.Join(dir, "a"), "/other/", "~/other") 	var got []*tree-	s.stop = func(ts []*tree, _ string) {+	s.stop = func(ts []*tree, _ string, _ bool) { 		got = ts 		for _, t := range ts { 			s.remove(t)

log_test.go

@@ -5,6 +5,7 @@ import ( 	"encoding/binary" 	"fmt" 	"net"+	"net/netip" 	"os" 	"path/filepath" 	"strings"@@ -23,6 +24,7 @@ func TestMain(m *testing.M) { 	os.Setenv("XDG_STATE_HOME", dir) 	journalSocket = filepath.Join(dir, "no-journal") 	journalStream = filepath.Join(dir, "no-journal-stream")+	bareEndpoint = func() (netip.AddrPort, bool) { return netip.AddrPort{}, false } 	code := m.Run() 	os.RemoveAll(dir) 	os.Exit(code)

main.go

@@ -19,6 +19,10 @@ import ( // readyEnv names the descriptor a detached child reports its start on. var readyEnv = envPrefix + "READY_FD" +// bareEnv, set by --restart, starts the server on the default address+// with no tree, so the web address beside it answers.+var bareEnv = envPrefix + "BARE"+ // Local runs the reader's executable on the process's arguments and // exits. It serves trees of this machine. func Local() {@@ -67,6 +71,13 @@ func Local() { 		} 	} +	if os.Getenv(bareEnv) != "" {+		c.dir = ""+		// The server itself starts nothing that should inherit it.+		if os.Getenv(readyEnv) != "" {+			os.Unsetenv(bareEnv)+		}+	} 	fd := os.Getenv(readyEnv) 	switch { 	case c.restart:

registry.go

@@ -144,6 +144,13 @@ func splitTarget(target string) (lockPath, token string) { // serves reports whether a live server holds a tree in the registry of ep. // The caller holds the lock. func (r *registry) serves(ep netip.AddrPort) bool {+	// The server on the default address stays up with no tree, so its+	// record alone says it serves.+	if _, ok := webEndpoint(ep, os.Getuid()); ok {+		if srv, up := serverOf(ep); up && !srv.foreign() {+			return true+		}+	} 	links, _ := r.links() 	for _, target := range links { 		if _, ok := readTree(ep, target); ok {

restart.go

@@ -35,6 +35,15 @@ func restart(c config) int { 	if named { 		eps = []netip.AddrPort{c.ep} 	}+	// This binary's default address gets a server even with no tree, so+	// the web address beside it answers at all times.+	var bare netip.AddrPort+	if def, ok := bareEndpoint(); ok && !named {+		bare = def+		if !slices.Contains(eps, def) {+			eps = append(eps, def)+		}+	} 	code := 0 	var open []string // pages that were open on c.ep's old server 	for _, ep := range eps {@@ -49,6 +58,11 @@ func restart(c config) int { 				continue 			} else if len(kept) > 0 { 				err = startTrees(ep, kept, c.debug, c.noBug, baseOf(ep))+			} else if srv, up := serverOf(ep); ep == bare && up && other != "" {+				say("the server on %s, pid %d, runs %s, so it stays; -f moves it to this binary", ep, srv.pid, other)+				continue+			} else if ep == bare {+				err = restartBare(ep, c.debug, c.noBug) 			} else if !named || c.dir != "" { 				continue 			}@@ -202,6 +216,66 @@ func restartServer(ep netip.AddrPort, pid int, trees []servedTree, debug, noBug 	return pages, startTrees(ep, trees, debug, noBug, base) } +// bareEndpoint is where --restart keeps a server with no tree: this+// binary's default address. Tests turn it off, since the server would+// run the test binary.+var bareEndpoint = func() (netip.AddrPort, bool) {+	ep, err := endpointFor("", os.Getuid())+	return ep, err == nil+}++// restartBare starts the server on ep with no tree, replacing one that+// runs with no tree, so the current binary serves the web address.+func restartBare(ep netip.AddrPort, debug, noBug bool) error {+	base := baseOf(ep)+	if srv, ok := strayServer(ep); ok {+		if ep.Port() < 1024 && !lowPortOK() {+			return &errno{syscall.EACCES, "this binary cannot bind port " + strconv.Itoa(int(ep.Port())) ++				", so the server on " + ep.String() + " keeps its old one. Run the installed package's " + progName + ", which holds cap_net_bind_service"}+		}+		if err := stopServer(ep, srv.pid, nil); err != nil {+			return err+		}+		say("the server on %s, which served no tree, is replaced", ep)+	}+	return startBare(ep, debug, noBug, base)+}++// startBare starts the server on ep with no tree through this binary.+func startBare(ep netip.AddrPort, debug, noBug bool, base string) error {+	if ep.Port() < 1024 && !lowPortOK() {+		return &errno{syscall.EACCES, "this binary cannot bind port " + strconv.Itoa(int(ep.Port())) ++			", so it cannot serve " + ep.String() + ". Run the installed package's " + progName + ", which holds cap_net_bind_service"}+	}+	exe, err := os.Executable()+	if err != nil {+		return &errno{errnoOf(err), "cannot find own executable: " + err.Error()}+	}+	args := []string{"--no-open", "-a", ep.String()}+	if debug {+		args = append(args, "--debug")+	}+	if noBug {+		args = append(args, "--no-bug")+	}+	if base != "" {+		args = append(args, "--base="+base)+	}+	cmd := exec.Command(exe, args...)+	cmd.Env = append(os.Environ(), bareEnv+"=1")+	cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr+	if err := cmd.Run(); err != nil {+		code := syscall.EIO+		var ee *exec.ExitError+		if errors.As(err, &ee) {+			code = syscall.Errno(ee.ExitCode())+		}+		// The child has printed its own error.+		return &errno{code, "cannot start the server with no tree on " + ep.String()}+	}+	return nil+}+ // startTrees serves each tree on ep through this binary, as a start from // the command line would, persistent ones with --persist. The first start // runs the server, so --debug, --no-bug and base, the base path of the

serve.go

@@ -66,6 +66,9 @@ func checkDir(path, home string) (string, error) { // run serves c.dir. It joins the server already on the endpoint, or becomes // that server. func run(c config, rep *reporter) int {+	if c.dir == "" {+		return runBare(c, rep)+	} 	home, _ := os.UserHomeDir() 	dir, err := checkDir(c.dir, home) 	if err != nil {@@ -146,6 +149,41 @@ func run(c config, rep *reporter) int { 	} } +// runBare starts the server on the default address with no tree, for the+// web address beside it, as --restart does at login. A server already+// there is left alone.+func runBare(c config, rep *reporter) int {+	web, ok := webEndpoint(c.ep, os.Getuid())+	if !ok {+		return rep.fail(syscall.EINVAL, "a server with no tree runs only on the default address; "+c.ep.String()+" is not it")+	}+	home, _ := os.UserHomeDir()+	reg, err := openRegistry(c.ep)+	if err != nil {+		return rep.fail(errnoOf(err), "cannot open the registry: "+err.Error())+	}+	if err := reg.lock(); err != nil {+		reg.close()+		return rep.fail(errnoOf(err), "cannot lock the registry "+reg.dir+": "+err.Error())+	}+	ln, err := net.Listen("tcp", c.ep.String())+	switch {+	case err == nil:+		return serve(c, rep, ln, reg, "", home, origin(c.ep))+	case errors.Is(err, syscall.EADDRINUSE) && reg.serves(c.ep):+		reg.close()+		rep.send("note", "a server already runs on "+c.ep.String()+"; online repos are at "+origin(web)+basePath+"/")+		rep.finish()+		return 0+	case errors.Is(err, syscall.EADDRINUSE):+		reg.close()+		return rep.fail(syscall.EADDRINUSE, taken(c.ep))+	default:+		reg.close()+		return rep.fail(errnoOf(err), "cannot listen on "+c.ep.String()+": "+err.Error())+	}+}+ // baseNote says that --base did not apply, when the server already on // c.ep has another base: a base belongs to a server, not to a tree. func baseNote(c config, rep *reporter) {@@ -275,9 +313,9 @@ func ifaceOf(a netip.Addr) string { 	return "any" } -// serve runs the server on ln with dir as its first tree. The caller holds-// the registry lock, which serve releases once dir is adopted and a crashed-// server's leftovers are gone.+// serve runs the server on ln with dir as its first tree, or with none when+// dir is "". The caller holds the registry lock, which serve releases once+// dir is adopted and a crashed server's leftovers are gone. func serve(c config, rep *reporter, ln net.Listener, reg *registry, dir, home, origin string) int { 	logInfo("server starts on %s: %s", c.ep, build()) 	go warmLexers()@@ -304,14 +342,31 @@ func serve(c config, rep *reporter, ln net.Listener, reg *registry, dir, home, o 	h.w.add(reg.dir) 	h.srv.shared = shared(c.ep) 	h.origin = origin+	// The web address starts before the first tree, whose warm-up reads+	// the cache's paths that startWeb sets. Its server stays up with no+	// tree, since the web address answers at all times; only a signal or+	// Kill server stops it.+	webEP, onDefault := webEndpoint(c.ep, os.Getuid())+	if onDefault {+		h.startWeb(c, webEP)+		h.stay = h.web != nil+	} 	first := lockName(c.ep) 	if c.persist { 		first = persistName(c.ep) 	}-	t, err := h.adopt(filepath.Join(dir, first), "", c.token)+	var t *tree+	var err error+	if dir != "" {+		t, err = h.adopt(filepath.Join(dir, first), "", c.token)+	} 	reg.unlock() 	if err != nil { 		ln.Close()+		if h.web != nil {+			h.webLn.Close()+			h.webStop()+		} 		return rep.fail(errnoOf(err), "cannot serve "+dir+": "+err.Error()) 	} 	h.srv.stop = h.stop@@ -321,6 +376,17 @@ func serve(c config, rep *reporter, ln net.Listener, reg *registry, dir, home, o 	h.httpd = &http.Server{Handler: h.srv.handler(), ReadHeaderTimeout: 10 * time.Second, ConnState: h.track, 		ErrorLog: log.New(logWriter{}, "", 0)} +	if t == nil && h.web == nil {+		code := rep.fail(syscall.EADDRNOTAVAIL, "cannot serve online repos on "+webEP.String()+", so a server with no tree has nothing to serve; the log says why")+		h.shutdown("it cannot serve online repos")+		<-h.done+		return code+	}+	if t == nil {+		rep.send("note", "serves no tree; online repos are at "+h.srv.webURL+"/")+		rep.finish()+	}+ 	sigs := make(chan os.Signal, 1) 	signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP) 	defer signal.Stop(sigs)@@ -333,12 +399,9 @@ func serve(c config, rep *reporter, ln net.Listener, reg *registry, dir, home, o 	}) 	h.bg.Go(h.loop) -	if ep, ok := webEndpoint(c.ep, os.Getuid()); ok {-		h.startWeb(c, ep)+	if t != nil {+		report(rep, c.ep, h.origin+t.prefixURL()) 	}--	url := h.origin + t.prefixURL()-	report(rep, c.ep, url) 	if err := h.httpd.Serve(ln); !h.halted.Load() { 		h.shutdown("cannot serve: " + err.Error()) 		<-h.done@@ -369,7 +432,7 @@ func signalName(sig os.Signal) string {  // hub keeps the served trees in line with their locks and the registry. It // adopts a tree that joins, withdraws a tree whose lock is gone, and stops-// the server with the last tree.+// the server with the last tree, unless the server stays. type hub struct { 	ep     netip.AddrPort 	origin string // the URL of this server, a name where it has one@@ -379,6 +442,9 @@ type hub struct { 	srv    *server 	ln     net.Listener 	httpd  *http.Server+	// stay keeps the server up with no tree: it serves the web address,+	// which answers at all times.+	stay bool 	// mu orders changes to the trees within this process, as the registry 	// flock does across processes. 	mu     sync.Mutex@@ -570,7 +636,7 @@ func (t *tree) ownsLink() bool { }  // sync withdraws every tree whose lock is gone and adopts every new link.-// When no tree is left it stops the server. It reports whether the server+// When no tree is left it stops the server, unless the server stays. It reports whether the server // still runs. func (h *hub) sync() bool { 	h.lock()@@ -598,7 +664,7 @@ func (h *hub) sync() bool { 			os.Remove(link) 		} 	}-	if len(h.srv.list()) == 0 {+	if len(h.srv.list()) == 0 && !h.stay { 		h.halt("its last tree is gone") 		return false 	}@@ -625,12 +691,16 @@ func (h *hub) loop() { }  // stop withdraws trees at the press of a button. The loop then stops the-// server if no tree is left.-func (h *hub) stop(trees []*tree, why string) {+// server if no tree is left. kill, from Kill server, stops it even when+// it stays.+func (h *hub) stop(trees []*tree, why string, kill bool) { 	h.lock() 	for _, t := range trees { 		h.withdraw(t, why, false) 	}+	if kill && len(h.srv.list()) == 0 {+		h.halt(why)+	} 	h.unlock() 	h.w.signal() }

serve_test.go

@@ -318,3 +318,107 @@ func TestOriginUnspecified(t *testing.T) { 		t.Errorf("0.0.0.0:8080: %s, want %s", got, want) 	} }++// defaultTestEndpoint is a free port on the user's default address, with+// the web address beside it free too, so a server there serves the web.+func defaultTestEndpoint(t *testing.T) netip.AddrPort {+	t.Helper()+	t.Setenv("XDG_STATE_HOME", t.TempDir())+	t.Setenv("XDG_CACHE_HOME", t.TempDir())+	def, err := endpointFor("", os.Getuid())+	if err != nil {+		t.Skip(err)+	}+	for range 20 {+		ln, err := net.Listen("tcp", netip.AddrPortFrom(def.Addr(), 0).String())+		if err != nil {+			t.Skip("cannot listen on the default address: ", err)+		}+		ep := netip.MustParseAddrPort(ln.Addr().String())+		web, _ := webEndpoint(ep, os.Getuid())+		wl, err := net.Listen("tcp", web.String())+		ln.Close()+		if err == nil {+			wl.Close()+			return ep+		}+	}+	t.Skip("no port free on both the default and the web address")+	return netip.AddrPort{}+}++// The server on the default address starts with no tree and stays up when+// its last tree goes, so the web address beside it answers at all times. A+// tree joins it as it joins any server, and --kill stops it.+func TestDefaultServerStaysWithNoTree(t *testing.T) {+	ep := defaultTestEndpoint(t)+	web, _ := webEndpoint(ep, os.Getuid())+	lines, served := start(t, config{ep: ep})+	if len(lines) != 1 || !strings.HasPrefix(lines[0], "note serves no tree; online repos are at http://"+web.String()+"/") {+		t.Fatalf("bare start report: %q", lines)+	}+	base := "http://" + ep.String()+	if code := status(t, base+"/"); code != http.StatusOK {+		t.Errorf("index of a server with no tree: status %d", code)+	}+	if code := status(t, "http://"+web.String()+"/"); code != http.StatusOK {+		t.Errorf("web address: status %d", code)+	}+	lines, again := start(t, config{ep: ep})+	if <-again != 0 || len(lines) != 1 || !strings.HasPrefix(lines[0], "note a server already runs on "+ep.String()) {+		t.Errorf("second bare start: %q", lines)+	}++	dir := t.TempDir()+	os.WriteFile(filepath.Join(dir, "a.txt"), []byte("a\n"), 0o644)+	lines, joined := start(t, config{dir: dir, ep: ep})+	if code := <-joined; code != 0 || lines[0] != "url "+base+dir+"/" {+		t.Fatalf("join of a server with no tree: %d %q", code, lines)+	}+	os.Remove(filepath.Join(dir, lockName(ep)))+	waitFor(t, "the tree to go", func() bool { return status(t, base+dir+"/a.txt?raw") == http.StatusNotFound })+	select {+	case code := <-served:+		t.Fatalf("the server exited with its last tree: %d", code)+	case <-time.After(300 * time.Millisecond):+	}+	if code := status(t, "http://"+web.String()+"/"); code != http.StatusOK {+		t.Errorf("web address after the last tree: status %d", code)+	}++	if code := kill(config{ep: ep, addr: ep.String()}); code != 0 {+		t.Errorf("kill exit %d", code)+	}+	select {+	case <-served:+	case <-time.After(5 * time.Second):+		t.Fatal("--kill left the server with no tree")+	}+}++// Kill server stops the server on the default address, which a lost last+// tree does not.+func TestKillServerStopsTheDefaultServer(t *testing.T) {+	ep := defaultTestEndpoint(t)+	dir := t.TempDir()+	lines, served := start(t, config{dir: dir, ep: ep})+	if !strings.HasPrefix(lines[0], "url ") {+		t.Fatalf("start: %q", lines)+	}+	base := "http://" + ep.String()+	req, _ := http.NewRequest(http.MethodPost, base+ownPath+"stop", nil)+	req.Header.Set("Origin", base)+	resp, err := http.DefaultClient.Do(req)+	if err != nil {+		t.Fatal(err)+	}+	resp.Body.Close()+	if resp.StatusCode != http.StatusGone {+		t.Fatalf("Kill server: status %d", resp.StatusCode)+	}+	select {+	case <-served:+	case <-time.After(5 * time.Second):+		t.Fatal("Kill server left the server on the default address")+	}+}

server.go

@@ -69,7 +69,7 @@ var csp = "default-src 'none'; script-src " + scriptSrc(liveJS) + "; connect-src type server struct { 	mu     sync.RWMutex 	trees  []*tree-	stop   func([]*tree, string) // withdraws trees for a cause; set by the hub+	stop   func([]*tree, string, bool) // withdraws trees for a cause, and stops the server on kill; set by the hub 	about  about 	shared bool   // on an address beyond loopback: it shows the trees and nothing of the machine 	public bool   // the web address of --public, which strangers reach by any name@@ -88,7 +88,7 @@ type server struct { }  func newServer() *server {-	return &server{stop: func([]*tree, string) {}}+	return &server{stop: func([]*tree, string, bool) {}} }  // local gives s what only the reader's executable serves.@@ -270,7 +270,7 @@ func (s *server) handleStop(w http.ResponseWriter, r *http.Request) { 		// index returns there, and a tree's page links it. 		if len(s.list()) > 1 { 			if r.PostFormValue("from") == "index" {-				s.stop(trees, why+" on the index")+				s.stop(trees, why+" on the index", false) 				http.Redirect(w, r, rooted("/"), http.StatusSeeOther) 				return 			}@@ -289,7 +289,7 @@ func (s *server) handleStop(w http.ResponseWriter, r *http.Request) { 	}) 	// stop only withdraws; the hub shuts down on its own goroutine, since 	// Shutdown waits for this response to finish.-	s.stop(trees, why)+	s.stop(trees, why, kill) }  // stoppedRows say what a stop ended, in a table as a 404's: each tree,

server_test.go

@@ -94,7 +94,7 @@ func TestCacheHeaders(t *testing.T) { func TestStopRefusesOtherSites(t *testing.T) { 	s, _, _ := serveTree(t) 	stopped := make(chan struct{}, 1)-	s.stop = func([]*tree, string) { stopped <- struct{}{} }+	s.stop = func([]*tree, string, bool) { stopped <- struct{}{} } 	h := s.handler() 	if rec := do(h, "POST", ownPath+"stop", "Sec-Fetch-Site", "cross-site"); rec.Code != http.StatusForbidden { 		t.Errorf("cross-site stop: status %d, want 403", rec.Code)@@ -200,7 +200,7 @@ func TestStopWithdrawsOneTree(t *testing.T) { 	s, tr, dir := serveTree(t) 	other := addTree(t, s, filepath.Join(dir, "a"), "/other/", "~/other") 	var got []*tree-	s.stop = func(ts []*tree, _ string) { got = ts }+	s.stop = func(ts []*tree, _ string, _ bool) { got = ts } 	body := get(s.handler(), "/other/").Body.String() 	if !strings.Contains(body, `<input type="hidden" name="tree" value="/other/">`) { 		t.Fatalf("tree page lacks its stop form: %s", body)

systemd/dev.service.in

@@ -2,7 +2,8 @@ # name, from login to logout. Enable it with: # systemctl --user enable @NAME@-dev # --restart starts a server for each address whose registry links a .LOCK-# and names this build. The package's units serve the trees its binary+# and names this build, and one on the build's default address with no+# tree, so the web address answers. The package's units serve the trees its binary # served last, so this unit runs beside them. # Stopping the unit sends its servers SIGTERM, which keeps every .LOCK. [Unit]

systemd/system@.service.in

@@ -1,4 +1,5 @@-# The system template serves a user's .LOCK trees from boot, before login.+# The system template serves a user's .LOCK trees from boot, before login,+# and the web address beside the user's default address. # Enable it for one user with: sudo systemctl enable @NAME@@<user> # The capability lets it bind port 80, as the package's binary may. # While the user unit runs in that user's session it serves the same

systemd/user.service.in

@@ -1,6 +1,7 @@ # The user unit serves the trees that .LOCK files name, from login to # logout. Enable it with: systemctl --user enable @NAME@-# --restart starts a server for each address whose registry links a .LOCK.+# --restart starts a server for each address whose registry links a .LOCK,+# and one on the default address with no tree, so the web address answers. # Stopping the unit sends its servers SIGTERM, which keeps every .LOCK. # While the system template runs for this user it serves the same trees # from boot, so this unit stands aside.