diff --git a/src/lib/haproxy/index.ts b/src/lib/haproxy/index.ts index 8781cbc0e..cda1cd1c1 100644 --- a/src/lib/haproxy/index.ts +++ b/src/lib/haproxy/index.ts @@ -105,55 +105,51 @@ export async function forceSSLOffApplication({ domain }) { } } export async function forceSSLOnApplication({ domain }) { - if (!dev) { - const haproxy = await haproxyInstance(); - await checkHAProxy(haproxy); - let transactionId; - try { - const rules: any = await haproxy - .get(`v2/services/haproxy/configuration/http_request_rules`, { - searchParams: { - parent_name: 'http', - parent_type: 'frontend' - } - }) - .json(); - let nextRule = 0; - if (rules.data.length > 0) { - const rule = rules.data.find((rule) => - rule.cond_test.includes(`{ hdr(host) -i ${domain} } !{ ssl_fc }`) - ); - if (rule) return; - nextRule = rules.data[rules.data.length - 1].index + 1; - } - transactionId = await getNextTransactionId(); - - await haproxy - .post(`v2/services/haproxy/configuration/http_request_rules`, { - searchParams: { - transaction_id: transactionId, - parent_name: 'http', - parent_type: 'frontend' - }, - json: { - index: nextRule, - cond: 'if', - cond_test: `{ hdr(host) -i ${domain} } !{ ssl_fc }`, - type: 'redirect', - redir_type: 'scheme', - redir_value: 'https', - redir_code: 301 - } - }) - .json(); - } catch (error) { - console.log(error); - throw error; - } finally { - if (transactionId) await completeTransaction(transactionId); + const haproxy = await haproxyInstance(); + await checkHAProxy(haproxy); + let transactionId; + try { + const rules: any = await haproxy + .get(`v2/services/haproxy/configuration/http_request_rules`, { + searchParams: { + parent_name: 'http', + parent_type: 'frontend' + } + }) + .json(); + let nextRule = 0; + if (rules.data.length > 0) { + const rule = rules.data.find((rule) => + rule.cond_test.includes(`{ hdr(host) -i ${domain} } !{ ssl_fc }`) + ); + if (rule) return; + nextRule = rules.data[rules.data.length - 1].index + 1; } - } else { - console.log(`[DEBUG] Adding ssl for ${domain}`); + transactionId = await getNextTransactionId(); + + await haproxy + .post(`v2/services/haproxy/configuration/http_request_rules`, { + searchParams: { + transaction_id: transactionId, + parent_name: 'http', + parent_type: 'frontend' + }, + json: { + index: nextRule, + cond: 'if', + cond_test: `{ hdr(host) -i ${domain} } !{ ssl_fc }`, + type: 'redirect', + redir_type: 'scheme', + redir_value: 'https', + redir_code: dev ? 302 : 301 + } + }) + .json(); + } catch (error) { + console.log(error); + throw error; + } finally { + if (transactionId) await completeTransaction(transactionId); } } diff --git a/src/lib/queues/builder.ts b/src/lib/queues/builder.ts index 05c9b19dd..2e7fe2475 100644 --- a/src/lib/queues/builder.ts +++ b/src/lib/queues/builder.ts @@ -261,6 +261,7 @@ export default async function (job) { } catch (error) { saveBuildLog({ line: error.stdout || error, buildId, applicationId }); sentry.captureException(error); + throw new Error(error); } } } diff --git a/src/lib/queues/index.ts b/src/lib/queues/index.ts index f8525c4e0..3d0dda4f1 100644 --- a/src/lib/queues/index.ts +++ b/src/lib/queues/index.ts @@ -127,7 +127,6 @@ buildWorker.on('completed', async (job: Bullmq.Job) => { }); buildWorker.on('failed', async (job: Bullmq.Job, failedReason) => { - console.log(failedReason); try { await prisma.build.update({ where: { id: job.data.build_id }, data: { status: 'failed' } }); } catch (error) { @@ -136,7 +135,11 @@ buildWorker.on('failed', async (job: Bullmq.Job, failedReason) => { const workdir = `/tmp/build-sources/${job.data.repository}`; await asyncExecShell(`rm -fr ${workdir}`); } - saveBuildLog({ line: 'Failed build!', buildId: job.data.build_id, applicationId: job.data.id }); + saveBuildLog({ + line: 'Failed to deploy!', + buildId: job.data.build_id, + applicationId: job.data.id + }); saveBuildLog({ line: `Reason: ${failedReason.toString()}`, buildId: job.data.build_id, diff --git a/src/routes/applications/[id]/logs/build/index.svelte b/src/routes/applications/[id]/logs/build/index.svelte index 7f7e24e46..6ce49f78a 100644 --- a/src/routes/applications/[id]/logs/build/index.svelte +++ b/src/routes/applications/[id]/logs/build/index.svelte @@ -82,7 +82,7 @@ } async function loadBuild(build) { buildId = build; - goto(`/applications/${id}/logs/build?buildId=${buildId}`); + await goto(`/applications/${id}/logs/build?buildId=${buildId}`); } @@ -94,13 +94,15 @@