release: harden plugin deployment and recovery
This commit is contained in:
@@ -44,7 +44,7 @@ import (
|
||||
const (
|
||||
pluginID = "qiu.plugin-admin"
|
||||
subscriptionPluginID = "qiu.subscription-admin"
|
||||
pluginVersion = "1.1.0"
|
||||
pluginVersion = "1.1.1"
|
||||
sessionCookieName = "plugin_admin_session"
|
||||
maxJSONBytes = 2 << 20
|
||||
maxPackageBytes = 128 << 20
|
||||
@@ -2668,18 +2668,25 @@ func (a *app) startRevision(p *pluginRecord, revisionID, processKey string) (str
|
||||
probe.Endpoint = endpoint
|
||||
var probeErr error
|
||||
attempts := 1
|
||||
probeDelay := 50 * time.Millisecond
|
||||
var startupDeadline time.Time
|
||||
if pluginManifest.Backend.Command != "" {
|
||||
// A freshly spawned process can need a short interval before binding its
|
||||
// port. Retry the probe within the bounded startup window.
|
||||
attempts = 20
|
||||
// A freshly spawned interpreter-backed process can need several seconds
|
||||
// before binding its port (notably on macOS under concurrent test load).
|
||||
// Keep the window bounded while avoiding a fixed one-second flake.
|
||||
attempts = 100
|
||||
startupDeadline = time.Now().Add(5 * time.Second)
|
||||
}
|
||||
for attempt := 0; attempt < attempts; attempt++ {
|
||||
if !startupDeadline.IsZero() && time.Now().After(startupDeadline) {
|
||||
break
|
||||
}
|
||||
probeErr = a.checkPluginHealth(&probe)
|
||||
if probeErr == nil {
|
||||
break
|
||||
}
|
||||
if attempt+1 < attempts {
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
if attempt+1 < attempts && (startupDeadline.IsZero() || time.Now().Add(probeDelay).Before(startupDeadline)) {
|
||||
time.Sleep(probeDelay)
|
||||
}
|
||||
}
|
||||
if probeErr != nil {
|
||||
|
||||
Reference in New Issue
Block a user