Supervisor probes before spawning: an external server on the port is used, never fought or killed
This commit is contained in:
@@ -29,6 +29,7 @@ type Process struct {
|
||||
cmd *exec.Cmd
|
||||
stopping bool
|
||||
ready bool
|
||||
external bool // someone else serves the port; not our process
|
||||
lastActivity time.Time
|
||||
}
|
||||
|
||||
@@ -118,7 +119,10 @@ func (p *Process) NoteActivity() {
|
||||
|
||||
// EnsureRunning starts the child if it is not running. It returns as soon
|
||||
// as the process is spawned; readiness is WaitReady's job (and the proxy's
|
||||
// retry backoff bridges the gap for plain proxied requests).
|
||||
// retry backoff bridges the gap for plain proxied requests). When the URL
|
||||
// already answers — e.g. the ComfyUI desktop app grabbed the port — no
|
||||
// child is spawned: the external server is used as-is, and the idle
|
||||
// watcher never touches it (it only kills its own child).
|
||||
func (p *Process) EnsureRunning() error {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
@@ -126,6 +130,18 @@ func (p *Process) EnsureRunning() error {
|
||||
if p.cmd != nil {
|
||||
return nil
|
||||
}
|
||||
pctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
err := p.probe(pctx)
|
||||
cancel()
|
||||
if err == nil {
|
||||
p.ready = true
|
||||
if !p.external {
|
||||
p.external = true
|
||||
p.log.Info(p.name + " is already served externally; not spawning a managed instance")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
p.external = false
|
||||
cmd := exec.Command(p.argv[0], p.argv[1:]...)
|
||||
cmd.Dir = p.dir
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
|
||||
Reference in New Issue
Block a user