fix: use Dokploy API status check instead of HTTP health check
The portal container cannot reach deployed stacks via external URL. Now checks applicationStatus via Dokploy API instead.
This commit is contained in:
@@ -347,53 +347,32 @@ export class ProductionDeployer {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
state.phase = 'verifying_health';
|
state.phase = 'verifying_health';
|
||||||
state.progress = 95;
|
state.progress = 95;
|
||||||
state.message = 'Verifying application health';
|
state.message = 'Verifying application status via Dokploy';
|
||||||
|
|
||||||
if (!state.url) {
|
if (!state.resources.applicationId) {
|
||||||
throw new Error('Application URL not available');
|
throw new Error('Application ID not available');
|
||||||
}
|
}
|
||||||
|
|
||||||
const timeout = config.healthCheckTimeout || 120000;
|
const timeout = config.healthCheckTimeout || 60000;
|
||||||
const interval = config.healthCheckInterval || 5000;
|
const interval = config.healthCheckInterval || 3000;
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
|
|
||||||
const endpoints = ['/', '/health', '/api'];
|
|
||||||
|
|
||||||
while (Date.now() - startTime < timeout) {
|
while (Date.now() - startTime < timeout) {
|
||||||
for (const endpoint of endpoints) {
|
try {
|
||||||
try {
|
const app = await this.client.getApplication(state.resources.applicationId);
|
||||||
const checkUrl = `${state.url}${endpoint}`;
|
const appStatus = app.applicationStatus;
|
||||||
const controller = new AbortController();
|
console.log(`Application status: ${appStatus}`);
|
||||||
const timeoutId = setTimeout(() => controller.abort(), 5000);
|
|
||||||
|
if (appStatus === 'done') {
|
||||||
const response = await fetch(checkUrl, {
|
state.message = 'Application deployed successfully';
|
||||||
method: 'GET',
|
|
||||||
signal: controller.signal,
|
|
||||||
});
|
|
||||||
|
|
||||||
clearTimeout(timeoutId);
|
|
||||||
console.log(`Health check ${checkUrl} returned ${response.status}`);
|
|
||||||
state.message = 'Application is responding';
|
|
||||||
return;
|
return;
|
||||||
} catch (error) {
|
|
||||||
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
||||||
|
|
||||||
if (
|
|
||||||
errorMsg.includes('certificate') ||
|
|
||||||
errorMsg.includes('SSL') ||
|
|
||||||
errorMsg.includes('TLS') ||
|
|
||||||
errorMsg.includes('CERT') ||
|
|
||||||
errorMsg.includes('unable to verify') ||
|
|
||||||
errorMsg.includes('self signed') ||
|
|
||||||
errorMsg.includes('self-signed')
|
|
||||||
) {
|
|
||||||
console.log(`Health check SSL error (treating as alive): ${errorMsg}`);
|
|
||||||
state.message = 'Application is responding (SSL provisioning)';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`Health check failed: ${errorMsg}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (appStatus === 'error') {
|
||||||
|
throw new Error('Application deployment failed in Dokploy');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(`Status check failed: ${error}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const elapsed = Math.round((Date.now() - startTime) / 1000);
|
const elapsed = Math.round((Date.now() - startTime) / 1000);
|
||||||
@@ -403,7 +382,7 @@ export class ProductionDeployer {
|
|||||||
await this.sleep(interval);
|
await this.sleep(interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error('Health check timeout - application did not become healthy');
|
throw new Error('Health check timeout - application did not become ready');
|
||||||
}
|
}
|
||||||
|
|
||||||
private async rollback(state: DeploymentState): Promise<void> {
|
private async rollback(state: DeploymentState): Promise<void> {
|
||||||
|
|||||||
Reference in New Issue
Block a user