fix: Lets await!

This commit is contained in:
Andras Bacsai 2022-04-03 22:53:11 +02:00
parent c36bd34a1a
commit 53947d805b
5 changed files with 20 additions and 12 deletions

View File

@ -140,7 +140,11 @@ export async function copyBaseConfigurationFiles(buildPack, workdir, buildId, ap
` `
); );
await fs.writeFile(`${workdir}/entrypoint.sh`, `chown -R 1000 /app`); await fs.writeFile(`${workdir}/entrypoint.sh`, `chown -R 1000 /app`);
saveBuildLog({ line: 'Copied default configuration file for PHP.', buildId, applicationId }); await saveBuildLog({
line: 'Copied default configuration file for PHP.',
buildId,
applicationId
});
} else if (staticDeployments.includes(buildPack)) { } else if (staticDeployments.includes(buildPack)) {
await fs.writeFile( await fs.writeFile(
`${workdir}/nginx.conf`, `${workdir}/nginx.conf`,
@ -194,7 +198,7 @@ export async function copyBaseConfigurationFiles(buildPack, workdir, buildId, ap
} }
` `
); );
saveBuildLog({ line: 'Copied default configuration file.', buildId, applicationId }); await saveBuildLog({ line: 'Copied default configuration file.', buildId, applicationId });
} }
} catch (error) { } catch (error) {
console.log(error); console.log(error);

View File

@ -88,12 +88,12 @@ export async function buildImage({
debug = false debug = false
}) { }) {
if (isCache) { if (isCache) {
saveBuildLog({ line: `Building cache image started.`, buildId, applicationId }); await saveBuildLog({ line: `Building cache image started.`, buildId, applicationId });
} else { } else {
saveBuildLog({ line: `Building image started.`, buildId, applicationId }); await saveBuildLog({ line: `Building image started.`, buildId, applicationId });
} }
if (!debug && isCache) { if (!debug && isCache) {
saveBuildLog({ await saveBuildLog({
line: `Debug turned off. To see more details, allow it in the configuration.`, line: `Debug turned off. To see more details, allow it in the configuration.`,
buildId, buildId,
applicationId applicationId
@ -132,7 +132,11 @@ export async function streamEvents({ stream, docker, buildId, applicationId, deb
} else if (event.stream) { } else if (event.stream) {
if (event.stream !== '\n') { if (event.stream !== '\n') {
if (debug) if (debug)
saveBuildLog({ line: `${event.stream.replace('\n', '')}`, buildId, applicationId }); await saveBuildLog({
line: `${event.stream.replace('\n', '')}`,
buildId,
applicationId
});
} }
} }
} }

View File

@ -14,7 +14,7 @@ export default async function ({
buildId buildId
}): Promise<any> { }): Promise<any> {
try { try {
saveBuildLog({ line: 'GitHub importer started.', buildId, applicationId }); await saveBuildLog({ line: 'GitHub importer started.', buildId, applicationId });
const { privateKey, appId, installationId } = await db.getUniqueGithubApp({ githubAppId }); const { privateKey, appId, installationId } = await db.getUniqueGithubApp({ githubAppId });
const githubPrivateKey = privateKey.replace(/\\n/g, '\n').replace(/"/g, ''); const githubPrivateKey = privateKey.replace(/\\n/g, '\n').replace(/"/g, '');
@ -34,7 +34,7 @@ export default async function ({
} }
}) })
.json(); .json();
saveBuildLog({ await saveBuildLog({
line: `Cloning ${repository}:${branch} branch.`, line: `Cloning ${repository}:${branch} branch.`,
buildId, buildId,
applicationId applicationId

View File

@ -11,11 +11,11 @@ export default async function ({
buildId, buildId,
privateSshKey privateSshKey
}): Promise<any> { }): Promise<any> {
saveBuildLog({ line: 'GitLab importer started.', buildId, applicationId }); await saveBuildLog({ line: 'GitLab importer started.', buildId, applicationId });
await asyncExecShell(`echo '${privateSshKey}' > ${repodir}/id.rsa`); await asyncExecShell(`echo '${privateSshKey}' > ${repodir}/id.rsa`);
await asyncExecShell(`chmod 600 ${repodir}/id.rsa`); await asyncExecShell(`chmod 600 ${repodir}/id.rsa`);
saveBuildLog({ await saveBuildLog({
line: `Cloning ${repository}:${branch} branch.`, line: `Cloning ${repository}:${branch} branch.`,
buildId, buildId,
applicationId applicationId

View File

@ -135,12 +135,12 @@ buildWorker.on('failed', async (job: Bullmq.Job, failedReason) => {
const workdir = `/tmp/build-sources/${job.data.repository}`; const workdir = `/tmp/build-sources/${job.data.repository}`;
if (!dev) await asyncExecShell(`rm -fr ${workdir}`); if (!dev) await asyncExecShell(`rm -fr ${workdir}`);
} }
saveBuildLog({ await saveBuildLog({
line: 'Failed to deploy!', line: 'Failed to deploy!',
buildId: job.data.build_id, buildId: job.data.build_id,
applicationId: job.data.id applicationId: job.data.id
}); });
saveBuildLog({ await saveBuildLog({
line: `Reason: ${failedReason.toString()}`, line: `Reason: ${failedReason.toString()}`,
buildId: job.data.build_id, buildId: job.data.build_id,
applicationId: job.data.id applicationId: job.data.id