Join: mesh-knowledge's page address is no word of the environment
The overview page read MESH_KNOWLEDGE_PAGE, which nothing in the mesh sets; only its bus test did, to serve no page. checks/environment, which came with A3's merge, refuses such a read. The page listens on the port its manifest declares; the test's bundle sets the package's address empty instead. Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
This commit is contained in:
@@ -155,7 +155,7 @@ func (w *busWorld) start(t *testing.T) (*bundle, string) {
|
|||||||
_ = os.WriteFile(settings, []byte(`{"judge-model": "sonnet", "drafting": "off"}`), 0o600)
|
_ = os.WriteFile(settings, []byte(`{"judge-model": "sonnet", "drafting": "off"}`), 0o600)
|
||||||
status := filepath.Join(dir, "health.json")
|
status := filepath.Join(dir, "health.json")
|
||||||
cmd := exec.Command(os.Args[0], "-test.run=^$")
|
cmd := exec.Command(os.Args[0], "-test.run=^$")
|
||||||
cmd.Env = append(os.Environ(), bundleVar+"=1", "MESH_KNOWLEDGE_PAGE=off", "MESH_KNOWLEDGE_SETTINGS="+settings, "MESH_KNOWLEDGE_STATUS="+status,
|
cmd.Env = append(os.Environ(), bundleVar+"=1", "MESH_KNOWLEDGE_SETTINGS="+settings, "MESH_KNOWLEDGE_STATUS="+status,
|
||||||
"MESH_SERVED_MODULE="+Module, "MESH_MODULE="+Module, "MESH_NODE=test")
|
"MESH_SERVED_MODULE="+Module, "MESH_MODULE="+Module, "MESH_NODE=test")
|
||||||
in, _ := cmd.StdinPipe()
|
in, _ := cmd.StdinPipe()
|
||||||
out, _ := cmd.StdoutPipe()
|
out, _ := cmd.StdoutPipe()
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ func TestMain(m *testing.M) {
|
|||||||
// The bundle the bus test starts: the knowledge base as the runtime launches it, its store in memory.
|
// The bundle the bus test starts: the knowledge base as the runtime launches it, its store in memory.
|
||||||
k := newKB(newMemStore())
|
k := newKB(newMemStore())
|
||||||
k.Now = func() time.Time { return bundleDay }
|
k.Now = func() time.Time { return bundleDay }
|
||||||
|
pageAddress = ""
|
||||||
serve(k, os.Getenv("MESH_KNOWLEDGE_STATUS"))
|
serve(k, os.Getenv("MESH_KNOWLEDGE_STATUS"))
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,10 +16,14 @@ import (
|
|||||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PageAddress is where the page listens unless MESH_KNOWLEDGE_PAGE says otherwise: the port the manifest declares under
|
// PageAddress is where the page listens: the port the manifest declares under `listens`, which the node's packet filter
|
||||||
// `listens`, which the node's packet filter opens for this machine only.
|
// opens for this machine only.
|
||||||
const PageAddress = ":8480"
|
const PageAddress = ":8480"
|
||||||
|
|
||||||
|
// pageAddress is where this process serves the page; empty serves none (the bus test's bundle, which runs beside other
|
||||||
|
// tests on one machine). It is no word of the environment: nothing in the mesh sets one (checks/environment).
|
||||||
|
var pageAddress = PageAddress
|
||||||
|
|
||||||
// PageHandler renders the model as a page; any method but GET is refused, nothing is written.
|
// PageHandler renders the model as a page; any method but GET is refused, nothing is written.
|
||||||
func PageHandler(o *Overview) http.Handler {
|
func PageHandler(o *Overview) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -129,12 +133,9 @@ func ServePage(k *KB) {
|
|||||||
o.Due()
|
o.Due()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
addr := os.Getenv("MESH_KNOWLEDGE_PAGE")
|
addr := pageAddress
|
||||||
if addr == "" {
|
if addr == "" {
|
||||||
addr = PageAddress
|
return
|
||||||
}
|
|
||||||
if addr == "off" {
|
|
||||||
return // a test's bundle serves no page
|
|
||||||
}
|
}
|
||||||
srv := &http.Server{Addr: addr, Handler: PageHandler(o), ReadHeaderTimeout: 10 * time.Second}
|
srv := &http.Server{Addr: addr, Handler: PageHandler(o), ReadHeaderTimeout: 10 * time.Second}
|
||||||
logf("[mesh-knowledge] the overview page listens on %s", addr)
|
logf("[mesh-knowledge] the overview page listens on %s", addr)
|
||||||
|
|||||||
Reference in New Issue
Block a user