fix: use Dokploy API status check instead of HTTP health check
Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 16s
Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 16s
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> {
|
||||
state.phase = 'verifying_health';
|
||||
state.progress = 95;
|
||||
state.message = 'Verifying application health';
|
||||
state.message = 'Verifying application status via Dokploy';
|
||||
|
||||
if (!state.url) {
|
||||
throw new Error('Application URL not available');
|
||||
if (!state.resources.applicationId) {
|
||||
throw new Error('Application ID not available');
|
||||
}
|
||||
|
||||
const timeout = config.healthCheckTimeout || 120000;
|
||||
const interval = config.healthCheckInterval || 5000;
|
||||
const timeout = config.healthCheckTimeout || 60000;
|
||||
const interval = config.healthCheckInterval || 3000;
|
||||
const startTime = Date.now();
|
||||
|
||||
const endpoints = ['/', '/health', '/api'];
|
||||
|
||||
while (Date.now() - startTime < timeout) {
|
||||
for (const endpoint of endpoints) {
|
||||
try {
|
||||
const checkUrl = `${state.url}${endpoint}`;
|
||||
const controller = new AbortController();
|
||||
const timeoutId = setTimeout(() => controller.abort(), 5000);
|
||||
|
||||
const response = await fetch(checkUrl, {
|
||||
method: 'GET',
|
||||
signal: controller.signal,
|
||||
});
|
||||
|
||||
clearTimeout(timeoutId);
|
||||
console.log(`Health check ${checkUrl} returned ${response.status}`);
|
||||
state.message = 'Application is responding';
|
||||
try {
|
||||
const app = await this.client.getApplication(state.resources.applicationId);
|
||||
const appStatus = app.applicationStatus;
|
||||
console.log(`Application status: ${appStatus}`);
|
||||
|
||||
if (appStatus === 'done') {
|
||||
state.message = 'Application deployed successfully';
|
||||
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);
|
||||
@@ -403,7 +382,7 @@ export class ProductionDeployer {
|
||||
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> {
|
||||
|
||||
Reference in New Issue
Block a user