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: Minor fixes

Andras Bacsaic5348ce4b3ae
diff --git a/src/lib/haproxy/index.ts b/src/lib/haproxy/index.ts
index 8781cbc0e1..cda1cd1c18 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 05c9b19dd6..2e7fe24752 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 f8525c4e0f..3d0dda4f16 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 7f7e24e46c..6ce49f78a2 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}`);
}
</script>
@@ -94,13 +94,15 @@
<div class="block flex-row justify-start space-x-2 px-5 pt-6 sm:px-10 md:flex">
<div class="mb-4 min-w-[16rem] space-y-2 md:mb-0 ">
<div class="top-4 md:sticky">
- {#each builds as build (build.id)}
+ {#each builds as build, index (build.id)}
<div
data-tooltip={new Intl.DateTimeFormat('default', dateOptions).format(
new Date(build.createdAt)
) + `\n${build.status}`}
on:click={() => loadBuild(build.id)}
- class="tooltip-top flex cursor-pointer items-center justify-center rounded-r border-l-2 border-transparent py-4 no-underline transition-all duration-100 hover:bg-coolgray-400 hover:shadow-xl "
+ class:rounded-tr={index === 0}
+ class:rounded-br={index === builds.length - 1}
+ class="tooltip-top flex cursor-pointer items-center justify-center border-l-2 border-transparent py-4 no-underline transition-all duration-100 hover:bg-coolgray-400 hover:shadow-xl "
class:bg-coolgray-400={buildId === build.id}
class:border-red-500={build.status === 'failed'}
class:border-green-500={build.status === 'success'}
diff --git a/src/routes/settings/index.json.ts b/src/routes/settings/index.json.ts
index 41b68ef299..f12aa1f3b8 100644
--- a/src/routes/settings/index.json.ts
+++ b/src/routes/settings/index.json.ts
@@ -12,7 +12,7 @@ import {
} from '$lib/haproxy';
import { letsEncrypt } from '$lib/letsencrypt';
import type { RequestHandler } from '@sveltejs/kit';
-import dns from 'dns/promises';
+import { promises as dns } from 'dns';
export const get: RequestHandler = async (event) => {
const { status, body } = await getUserDetails(event);