Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: show error logs

Andras Bacsai61ea7dabae80
diff --git a/apps/api/src/jobs/deployApplication.ts b/apps/api/src/jobs/deployApplication.ts
index 5722dbcfb6..23adbf608c 100644
--- a/apps/api/src/jobs/deployApplication.ts
+++ b/apps/api/src/jobs/deployApplication.ts
@@ -357,7 +357,9 @@ import * as buildpacks from '../lib/buildPacks';
where: { id: buildId, status: { in: ['queued', 'running'] } },
data: { status: 'failed' }
});
- await saveBuildLog({ line: error, buildId, applicationId: application.id });
+ if (error !== 1) {
+ await saveBuildLog({ line: error, buildId, applicationId: application.id });
+ }
}
});
}
diff --git a/apps/api/src/lib/common.ts b/apps/api/src/lib/common.ts
index 530f95aa41..9378d72665 100644
--- a/apps/api/src/lib/common.ts
+++ b/apps/api/src/lib/common.ts
@@ -75,13 +75,15 @@ export const asyncExecShellStream = async ({ debug, buildId, applicationId, comm
return await new Promise(async (resolve, reject) => {
const { execaCommand } = await import('execa')
const subprocess = execaCommand(command, { env: { DOCKER_BUILDKIT: "1", DOCKER_HOST: engine } })
- if (debug) {
+ const errorLogs = []
+ const logs = []
subprocess.stdout.on('data', async (data) => {
const stdout = data.toString();
const array = stdout.split('\n')
for (const line of array) {
if (line !== '\n' && line !== '') {
- await saveBuildLog({
+ logs.push(line.replace('\n', ''))
+ debug && await saveBuildLog({
line: `${line.replace('\n', '')}`,
buildId,
applicationId
@@ -94,20 +96,29 @@ export const asyncExecShellStream = async ({ debug, buildId, applicationId, comm
const array = stderr.split('\n')
for (const line of array) {
if (line !== '\n' && line !== '') {
- await saveBuildLog({
+ errorLogs.push(line.replace('\n', ''))
+ debug && await saveBuildLog({
line: `${line.replace('\n', '')}`,
buildId,
applicationId
- });
+ });
}
}
})
- }
subprocess.on('exit', async (code) => {
await asyncSleep(1000);
if (code === 0) {
resolve(code)
} else {
+ if (!debug) {
+ for (const line of errorLogs) {
+ await saveBuildLog({
+ line: `${line.replace('\n', '')}`,
+ buildId,
+ applicationId
+ });
+ }
+ }
reject(code)
}
})