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