feat(platform-services): Add platform service log streaming, improve health checks and provisioning robustness
This commit is contained in:
@@ -93,6 +93,8 @@ export class PlatformServicesManager {
|
||||
}
|
||||
|
||||
// Check if already running
|
||||
let needsDeploy = platformService.status !== 'running';
|
||||
|
||||
if (platformService.status === 'running') {
|
||||
// Verify it's actually healthy
|
||||
const isHealthy = await provider.healthCheck();
|
||||
@@ -100,11 +102,14 @@ export class PlatformServicesManager {
|
||||
logger.debug(`${provider.displayName} is already running and healthy`);
|
||||
return platformService;
|
||||
}
|
||||
logger.warn(`${provider.displayName} reports running but health check failed, restarting...`);
|
||||
logger.warn(`${provider.displayName} reports running but health check failed, will redeploy...`);
|
||||
// Mark status as needing redeploy - container may have been recreated with different credentials
|
||||
this.oneboxRef.database.updatePlatformService(platformService.id!, { status: 'stopped' });
|
||||
needsDeploy = true;
|
||||
}
|
||||
|
||||
// Deploy if not running
|
||||
if (platformService.status !== 'running') {
|
||||
// Deploy if needed
|
||||
if (needsDeploy) {
|
||||
logger.info(`Starting ${provider.displayName} platform service...`);
|
||||
|
||||
try {
|
||||
@@ -143,19 +148,28 @@ export class PlatformServicesManager {
|
||||
*/
|
||||
private async waitForHealthy(type: TPlatformServiceType, timeoutMs: number): Promise<boolean> {
|
||||
const provider = this.providers.get(type);
|
||||
if (!provider) return false;
|
||||
if (!provider) {
|
||||
logger.warn(`waitForHealthy: no provider for type ${type}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
logger.info(`waitForHealthy: starting health check loop for ${type} (timeout: ${timeoutMs}ms)`);
|
||||
const startTime = Date.now();
|
||||
const checkInterval = 2000; // Check every 2 seconds
|
||||
let checkCount = 0;
|
||||
|
||||
while (Date.now() - startTime < timeoutMs) {
|
||||
checkCount++;
|
||||
logger.info(`waitForHealthy: health check attempt #${checkCount} for ${type}`);
|
||||
const isHealthy = await provider.healthCheck();
|
||||
if (isHealthy) {
|
||||
logger.info(`waitForHealthy: ${type} became healthy after ${checkCount} attempts`);
|
||||
return true;
|
||||
}
|
||||
await new Promise((resolve) => setTimeout(resolve, checkInterval));
|
||||
}
|
||||
|
||||
logger.warn(`waitForHealthy: ${type} did not become healthy after ${checkCount} attempts (${timeoutMs}ms)`);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user