P-0000: Agent (Minimalfassung, Go) holt die Projekt-ID lokal, init.sh und projekt_id.sh nutzen ihn, Tests projekt2id.1 bis .3 mit echtem Agenten (#1024), Plugin 0.3.3
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
32
agent/main.go
Normal file
32
agent/main.go
Normal file
@ -0,0 +1,32 @@
|
||||
// Projekt-Agent (Minimalfassung, #1024): beantwortet lokal die Anfrage nach der Projekt-ID.
|
||||
// Aufruf: projekt-agent [-config PFAD] serve
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
pfad := flag.String("config", "", "Konfigurationsdatei (Standard ~/.config/projekt-agent/agent.toml)")
|
||||
flag.Usage = func() {
|
||||
fmt.Fprintln(os.Stderr, "Aufruf: projekt-agent [-config PFAD] serve")
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
flag.Parse()
|
||||
if flag.NArg() != 1 || flag.Arg(0) != "serve" {
|
||||
flag.Usage()
|
||||
os.Exit(2)
|
||||
}
|
||||
cfg, err := LadeConfig(*pfad, os.Getenv)
|
||||
if err != nil {
|
||||
log.Fatalf("Konfiguration: %v", err)
|
||||
}
|
||||
srv := &http.Server{Addr: cfg.Listen, Handler: NeuerHandler(cfg), ReadHeaderTimeout: 5 * time.Second}
|
||||
log.Printf("Agent für %q hört auf %s, Register %s, Projektwurzel %s", cfg.Rechner, cfg.Listen, cfg.RegisterURL, cfg.Wurzel)
|
||||
log.Fatal(srv.ListenAndServe())
|
||||
}
|
||||
Reference in New Issue
Block a user