fix: Minor fixes
This commit is contained in:
		
							parent
							
								
									7f87c03f97
								
							
						
					
					
						commit
						c5348ce4b3
					
				| @ -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); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -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); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @ -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, | ||||
|  | ||||
| @ -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'} | ||||
|  | ||||
| @ -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); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user