fix: show error logs
This commit is contained in:
parent
5d9f5f4a7d
commit
61ea7dabae
@ -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 });
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -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,6 +96,22 @@ export const asyncExecShellStream = async ({ debug, buildId, applicationId, comm
|
||||
const array = stderr.split('\n')
|
||||
for (const line of array) {
|
||||
if (line !== '\n' && line !== '') {
|
||||
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,
|
||||
@ -101,13 +119,6 @@ export const asyncExecShellStream = async ({ debug, buildId, applicationId, comm
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
subprocess.on('exit', async (code) => {
|
||||
await asyncSleep(1000);
|
||||
if (code === 0) {
|
||||
resolve(code)
|
||||
} else {
|
||||
reject(code)
|
||||
}
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user