Add a standalone worker installer and dynamic userservice port
This commit is contained in:
@@ -30,16 +30,19 @@ func main() {
|
||||
switch args[0] {
|
||||
case "setup":
|
||||
if err := runSetup(args[1:]); err != nil {
|
||||
fmt.Fprintln(os.Stderr, "setup:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
return
|
||||
case "serve":
|
||||
if err := runServe(args[1:]); err != nil {
|
||||
fmt.Fprintln(os.Stderr, "serve:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
return
|
||||
case "agent":
|
||||
if err := runAgent(args[1:]); err != nil {
|
||||
fmt.Fprintln(os.Stderr, "agent:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
return
|
||||
|
||||
@@ -77,10 +77,10 @@ func Serve(ctx context.Context, cfg Config) (string, func() error, error) {
|
||||
handler := usershttp.NewServer(cfg.Log, uc, issuer)
|
||||
handler = http.TimeoutHandler(handler, 15*time.Second, `{"error":"request timeout"}`)
|
||||
|
||||
// A fixed loopback port lets the coordinator's proxy reuse its config
|
||||
// unchanged; collisions are unlikely (no other process binds 18081 on a
|
||||
// fresh machine) and fail loudly.
|
||||
listener, err := (&net.ListenConfig{}).Listen(ctx, "tcp", "127.0.0.1:18081")
|
||||
// Bind an ephemeral loopback port so a second serve instance can never
|
||||
// collide with the first; the coordinator's proxy uses the returned
|
||||
// address and needs no fixed-port assumption.
|
||||
listener, err := (&net.ListenConfig{}).Listen(ctx, "tcp", "127.0.0.1:0")
|
||||
if err != nil {
|
||||
_ = db.Close()
|
||||
return "", nil, fmt.Errorf("listen for embedded userservice: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user