feat(docker-watcher): phase 7 - deployer & health checker
Deploy orchestrator with full pipeline: pull → create container → start → network → NPM proxy → health check. Rollback on failure, multi-instance support, max_instances enforcement, webhook notifications. Fix NPM auth in rollback and error logging in removeInstance.
This commit is contained in:
@@ -387,12 +387,12 @@ func (d *Deployer) removeInstance(ctx context.Context, inst store.Instance, sett
|
||||
// Delete NPM proxy host.
|
||||
if inst.NpmProxyID > 0 {
|
||||
npmPassword, err := d.decryptNpmPassword(settings.NpmPassword)
|
||||
if err == nil {
|
||||
if authErr := d.npm.Authenticate(ctx, settings.NpmEmail, npmPassword); authErr == nil {
|
||||
if delErr := d.npm.DeleteProxyHost(ctx, inst.NpmProxyID); delErr != nil {
|
||||
log.Printf("deployer: delete proxy host %d: %v", inst.NpmProxyID, delErr)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
log.Printf("deployer: decrypt npm password for proxy cleanup: %v", err)
|
||||
} else if authErr := d.npm.Authenticate(ctx, settings.NpmEmail, npmPassword); authErr != nil {
|
||||
log.Printf("deployer: authenticate npm for proxy cleanup: %v", authErr)
|
||||
} else if delErr := d.npm.DeleteProxyHost(ctx, inst.NpmProxyID); delErr != nil {
|
||||
log.Printf("deployer: delete proxy host %d: %v", inst.NpmProxyID, delErr)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,17 @@ func (d *Deployer) rollback(ctx context.Context, deployID string, containerID st
|
||||
|
||||
// Delete the NPM proxy host if it was created.
|
||||
if npmProxyID > 0 {
|
||||
if err := d.npm.DeleteProxyHost(ctx, npmProxyID); err != nil {
|
||||
settings, err := d.store.GetSettings()
|
||||
if err != nil {
|
||||
log.Printf("rollback: get settings for npm auth: %v", err)
|
||||
d.logDeploy(deployID, fmt.Sprintf("Rollback: failed to get settings for proxy cleanup: %v", err), "error")
|
||||
} else if npmPassword, err := d.decryptNpmPassword(settings.NpmPassword); err != nil {
|
||||
log.Printf("rollback: decrypt npm password: %v", err)
|
||||
d.logDeploy(deployID, "Rollback: failed to decrypt NPM password for proxy cleanup", "error")
|
||||
} else if err := d.npm.Authenticate(ctx, settings.NpmEmail, npmPassword); err != nil {
|
||||
log.Printf("rollback: authenticate npm: %v", err)
|
||||
d.logDeploy(deployID, "Rollback: failed to authenticate NPM for proxy cleanup", "error")
|
||||
} else if err := d.npm.DeleteProxyHost(ctx, npmProxyID); err != nil {
|
||||
log.Printf("rollback: delete proxy host %d: %v", npmProxyID, err)
|
||||
d.logDeploy(deployID, fmt.Sprintf("Rollback: failed to delete proxy host: %v", err), "error")
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user