fix: show error logs
This commit is contained in:
@@ -357,7 +357,9 @@ import * as buildpacks from '../lib/buildPacks';
|
|||||||
where: { id: buildId, status: { in: ['queued', 'running'] } },
|
where: { id: buildId, status: { in: ['queued', 'running'] } },
|
||||||
data: { status: 'failed' }
|
data: { status: 'failed' }
|
||||||
});
|
});
|
||||||
await saveBuildLog({ line: error, buildId, applicationId: application.id });
|
if (error !== 1) {
|
||||||
|
await saveBuildLog({ line: error, buildId, applicationId: application.id });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -75,13 +75,15 @@ export const asyncExecShellStream = async ({ debug, buildId, applicationId, comm
|
|||||||
return await new Promise(async (resolve, reject) => {
|
return await new Promise(async (resolve, reject) => {
|
||||||
const { execaCommand } = await import('execa')
|
const { execaCommand } = await import('execa')
|
||||||
const subprocess = execaCommand(command, { env: { DOCKER_BUILDKIT: "1", DOCKER_HOST: engine } })
|
const subprocess = execaCommand(command, { env: { DOCKER_BUILDKIT: "1", DOCKER_HOST: engine } })
|
||||||
if (debug) {
|
const errorLogs = []
|
||||||
|
const logs = []
|
||||||
subprocess.stdout.on('data', async (data) => {
|
subprocess.stdout.on('data', async (data) => {
|
||||||
const stdout = data.toString();
|
const stdout = data.toString();
|
||||||
const array = stdout.split('\n')
|
const array = stdout.split('\n')
|
||||||
for (const line of array) {
|
for (const line of array) {
|
||||||
if (line !== '\n' && line !== '') {
|
if (line !== '\n' && line !== '') {
|
||||||
await saveBuildLog({
|
logs.push(line.replace('\n', ''))
|
||||||
|
debug && await saveBuildLog({
|
||||||
line: `${line.replace('\n', '')}`,
|
line: `${line.replace('\n', '')}`,
|
||||||
buildId,
|
buildId,
|
||||||
applicationId
|
applicationId
|
||||||
@@ -94,7 +96,8 @@ export const asyncExecShellStream = async ({ debug, buildId, applicationId, comm
|
|||||||
const array = stderr.split('\n')
|
const array = stderr.split('\n')
|
||||||
for (const line of array) {
|
for (const line of array) {
|
||||||
if (line !== '\n' && line !== '') {
|
if (line !== '\n' && line !== '') {
|
||||||
await saveBuildLog({
|
errorLogs.push(line.replace('\n', ''))
|
||||||
|
debug && await saveBuildLog({
|
||||||
line: `${line.replace('\n', '')}`,
|
line: `${line.replace('\n', '')}`,
|
||||||
buildId,
|
buildId,
|
||||||
applicationId
|
applicationId
|
||||||
@@ -102,12 +105,20 @@ export const asyncExecShellStream = async ({ debug, buildId, applicationId, comm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
subprocess.on('exit', async (code) => {
|
subprocess.on('exit', async (code) => {
|
||||||
await asyncSleep(1000);
|
await asyncSleep(1000);
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
resolve(code)
|
resolve(code)
|
||||||
} else {
|
} else {
|
||||||
|
if (!debug) {
|
||||||
|
for (const line of errorLogs) {
|
||||||
|
await saveBuildLog({
|
||||||
|
line: `${line.replace('\n', '')}`,
|
||||||
|
buildId,
|
||||||
|
applicationId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
reject(code)
|
reject(code)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user