Skip to content

Commit

Permalink
Handle unhealthy state. (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
eyeamnoob authored Jul 2, 2024
1 parent 27fa85b commit c2733bf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,10 @@ You may also want to switch to another region. Your current region is: ${chalk.c
return this.error(error.message);
}

if (error instanceof ReleaseFailed) {
return this.error(error.message);
}

if (
error instanceof ReachedMaxSourceSizeError ||
(error.response && error.response.statusCode === 413)
Expand Down Expand Up @@ -509,6 +513,12 @@ Additionally, you can also retry the build with the debug flag:
this.spinner.start('Creating a new release...');
}

if (output.state === 'UNHEALTHY') {
this.spinner.warn(
'App deployed, but the container is unhealthy. Please check its logs.',
);
}

if (output.state === 'BUILDING' && output.line) {
this.spinner.clear().frame();
process.stdout.write(output.line);
Expand Down Expand Up @@ -661,16 +671,16 @@ Additionally, you can also retry the build with the debug flag:
}

return reject(new Error('Release failed.'));
}

if (release.state === 'UNHEALTHY') {
} else if (release.state === 'UNHEALTHY') {
this.spinner.warn(
'App deployed, but the container has a problem. Please check its logs.',
'App deployed, but the container is unhealthy. Please check its logs.',
);
return resolve();
}

if (release.state === 'READY') {
return reject(
new ReleaseFailed(
'Release is not healthy. Check logs from web panel',
),
);
} else if (release.state === 'READY') {
this.spinner.succeed('Release created.');
return resolve();
}
Expand Down
9 changes: 9 additions & 0 deletions src/services/build-logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ export default async (
cb({ state: 'DEPLOYING' });
}

if (release.state === 'UNHEALTHY') {
cb({ state: 'UNHEALTHY' });
return reject(
new ReleaseFailed(
'Release is not healthy. Check logs from web panel',
),
);
}

if (release.state === 'READY') {
return resolve();
}
Expand Down

0 comments on commit c2733bf

Please sign in to comment.