fix: More error handling in proxy configuration + cleanups
This commit is contained in:
parent
02e0385ab8
commit
d88f2ea4c3
@ -1,6 +1,6 @@
|
||||
import { decrypt, encrypt } from '$lib/crypto';
|
||||
import { removeProxyConfiguration } from '$lib/haproxy';
|
||||
import { asyncExecShell, getEngine, removeContainer } from '$lib/common';
|
||||
import { asyncExecShell, getEngine } from '$lib/common';
|
||||
|
||||
import { getDomain, removeDestinationDocker } from '$lib/common';
|
||||
import { prisma } from './common';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { getDomain } from '$lib/common';
|
||||
import { prisma, PrismaErrorHandler } from './common';
|
||||
import { prisma } from './common';
|
||||
|
||||
export async function isBranchAlreadyUsed({ repository, branch, id }) {
|
||||
const application = await prisma.application.findUnique({
|
||||
|
@ -114,15 +114,6 @@ export async function updateDatabase({
|
||||
});
|
||||
}
|
||||
|
||||
// export async function setDatabaseSettings({ id, isPublic }) {
|
||||
// try {
|
||||
// await prisma.databaseSettings.update({ where: { databaseId: id }, data: { isPublic } })
|
||||
// return { status: 201 }
|
||||
// } catch (e) {
|
||||
// throw PrismaErrorHandler(e)
|
||||
// }
|
||||
// }
|
||||
|
||||
export async function stopDatabase(database) {
|
||||
let everStarted = false;
|
||||
const {
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { asyncExecShell, getEngine } from '$lib/common';
|
||||
import { dockerInstance } from '$lib/docker';
|
||||
import { defaultProxyImageHttp, defaultProxyImageTcp, startCoolifyProxy } from '$lib/haproxy';
|
||||
import { startCoolifyProxy } from '$lib/haproxy';
|
||||
import { getDatabaseImage } from '.';
|
||||
import { prisma, PrismaErrorHandler } from './common';
|
||||
import { prisma } from './common';
|
||||
|
||||
export async function listDestinations(teamId) {
|
||||
return await prisma.destinationDocker.findMany({ where: { teams: { some: { id: teamId } } } });
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { decrypt, encrypt } from '$lib/crypto';
|
||||
import { prisma, PrismaErrorHandler } from './common';
|
||||
import { prisma } from './common';
|
||||
|
||||
export async function listSources(teamId) {
|
||||
return await prisma.gitSource.findMany({
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { decrypt, encrypt } from '$lib/crypto';
|
||||
import { prisma, PrismaErrorHandler } from './common';
|
||||
import { prisma } from './common';
|
||||
|
||||
export async function addInstallation({ gitSourceId, installation_id }) {
|
||||
const source = await prisma.gitSource.findUnique({
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { encrypt } from '$lib/crypto';
|
||||
import { generateSshKeyPair, prisma, PrismaErrorHandler } from './common';
|
||||
import { generateSshKeyPair, prisma } from './common';
|
||||
|
||||
export async function updateDeployKey({ id, deployKeyId }) {
|
||||
const application = await prisma.application.findUnique({
|
||||
|
@ -7,7 +7,7 @@ export async function listLogs({ buildId, last = 0 }) {
|
||||
orderBy: { time: 'asc' }
|
||||
});
|
||||
return [...body];
|
||||
} catch (e) {
|
||||
throw PrismaErrorHandler(e);
|
||||
} catch (error) {
|
||||
return PrismaErrorHandler(error);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { encrypt } from '$lib/crypto';
|
||||
import { prisma, PrismaErrorHandler } from './common';
|
||||
import { prisma } from './common';
|
||||
|
||||
export async function listSecrets({ applicationId }) {
|
||||
return await prisma.secret.findMany({
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { decrypt, encrypt } from '$lib/crypto';
|
||||
import { dockerInstance } from '$lib/docker';
|
||||
import cuid from 'cuid';
|
||||
import { generatePassword } from '.';
|
||||
import { prisma, PrismaErrorHandler } from './common';
|
||||
import { prisma } from './common';
|
||||
|
||||
export async function listServices(teamId) {
|
||||
return await prisma.service.findMany({ where: { teams: { some: { id: teamId } } } });
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { prisma, PrismaErrorHandler } from './common';
|
||||
import { prisma } from './common';
|
||||
|
||||
export async function listTeams() {
|
||||
return await prisma.team.findMany();
|
||||
|
@ -1,8 +1,8 @@
|
||||
import cuid from 'cuid';
|
||||
import bcrypt from 'bcrypt';
|
||||
|
||||
import { prisma, PrismaErrorHandler } from './common';
|
||||
import { asyncExecShell, removeContainer, uniqueName } from '$lib/common';
|
||||
import { prisma } from './common';
|
||||
import { asyncExecShell, uniqueName } from '$lib/common';
|
||||
|
||||
import * as db from '$lib/database';
|
||||
import { startCoolifyProxy } from '$lib/haproxy';
|
||||
|
@ -7,6 +7,7 @@ import { asyncExecShell, createDirectories, getDomain, getEngine, saveBuildLog }
|
||||
import { configureProxyForApplication, reloadHaproxy } from '../haproxy';
|
||||
import * as db from '$lib/database';
|
||||
import { decrypt } from '$lib/crypto';
|
||||
import { sentry } from '$lib/common';
|
||||
import {
|
||||
copyBaseConfigurationFiles,
|
||||
makeLabelForStandaloneApplication,
|
||||
@ -246,19 +247,22 @@ export default async function (job) {
|
||||
} catch (error) {
|
||||
throw new Error(error);
|
||||
}
|
||||
|
||||
if (destinationDockerId && destinationDocker.isCoolifyProxyUsed) {
|
||||
saveBuildLog({ line: 'Proxy configuration started!', buildId, applicationId });
|
||||
await configureProxyForApplication({ domain, imageId, applicationId, port });
|
||||
if (isHttps) await letsEncrypt({ domain, id: applicationId });
|
||||
await reloadHaproxy(destinationDocker.engine);
|
||||
saveBuildLog({ line: 'Proxy configuration successful!', buildId, applicationId });
|
||||
} else {
|
||||
saveBuildLog({
|
||||
line: 'Coolify Proxy is not configured for this destination. Nothing else to do.',
|
||||
buildId,
|
||||
applicationId
|
||||
});
|
||||
try {
|
||||
if (destinationDockerId && destinationDocker.isCoolifyProxyUsed) {
|
||||
saveBuildLog({ line: 'Proxy configuration started!', buildId, applicationId });
|
||||
await configureProxyForApplication({ domain, imageId, applicationId, port });
|
||||
if (isHttps) await letsEncrypt({ domain, id: applicationId });
|
||||
await reloadHaproxy(destinationDocker.engine);
|
||||
saveBuildLog({ line: 'Proxy configuration successful!', buildId, applicationId });
|
||||
} else {
|
||||
saveBuildLog({
|
||||
line: 'Coolify Proxy is not configured for this destination. Nothing else to do.',
|
||||
buildId,
|
||||
applicationId
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
sentry.captureException(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user