fix
This commit is contained in:
parent
b0a7b1eb3d
commit
eb26787079
@ -45,18 +45,30 @@ async function checkProxies() {
|
|||||||
let portReachable;
|
let portReachable;
|
||||||
|
|
||||||
const { arch, ipv4, ipv6 } = await listSettings();
|
const { arch, ipv4, ipv6 } = await listSettings();
|
||||||
|
|
||||||
// Coolify Proxy local
|
// Coolify Proxy local
|
||||||
const engine = '/var/run/docker.sock';
|
const engine = '/var/run/docker.sock';
|
||||||
const localDocker = await prisma.destinationDocker.findFirst({
|
const localDocker = await prisma.destinationDocker.findFirst({
|
||||||
where: { engine, network: 'coolify' }
|
where: { engine, network: 'coolify', isCoolifyProxyUsed: true }
|
||||||
});
|
});
|
||||||
if (localDocker && localDocker.isCoolifyProxyUsed) {
|
if (localDocker) {
|
||||||
portReachable = await isReachable(80, { host: ipv4 || ipv6 })
|
portReachable = await isReachable(80, { host: ipv4 || ipv6 })
|
||||||
if (!portReachable) {
|
if (!portReachable) {
|
||||||
await startTraefikProxy(localDocker.id);
|
await startTraefikProxy(localDocker.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Coolify Proxy remote
|
||||||
|
const remoteDocker = await prisma.destinationDocker.findMany({
|
||||||
|
where: { engine, isCoolifyProxyUsed: true, remoteEngine: true }
|
||||||
|
});
|
||||||
|
if (remoteDocker.length > 0) {
|
||||||
|
for (const docker of remoteDocker) {
|
||||||
|
portReachable = await isReachable(80, { host: docker.remoteIpAddress })
|
||||||
|
if (!portReachable) {
|
||||||
|
await startTraefikProxy(docker.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// TCP Proxies
|
// TCP Proxies
|
||||||
const databasesWithPublicPort = await prisma.database.findMany({
|
const databasesWithPublicPort = await prisma.database.findMany({
|
||||||
where: { publicPort: { not: null } },
|
where: { publicPort: { not: null } },
|
||||||
|
@ -459,13 +459,7 @@ export async function createRemoteEngineConfiguration(id: string) {
|
|||||||
// Needed for remote docker compose
|
// Needed for remote docker compose
|
||||||
const { stdout: numberOfSSHAgentsRunning } = await asyncExecShell(`ps ax | grep [s]sh-agent | grep coolify-ssh-agent.pid | grep -v grep | wc -l`)
|
const { stdout: numberOfSSHAgentsRunning } = await asyncExecShell(`ps ax | grep [s]sh-agent | grep coolify-ssh-agent.pid | grep -v grep | wc -l`)
|
||||||
if (numberOfSSHAgentsRunning !== '' && Number(numberOfSSHAgentsRunning.trim()) == 0) {
|
if (numberOfSSHAgentsRunning !== '' && Number(numberOfSSHAgentsRunning.trim()) == 0) {
|
||||||
try {
|
await asyncExecShell(`eval $(ssh-agent -sa /tmp/coolify-ssh-agent.pid)`)
|
||||||
const {stdout, stderr } = await asyncExecShell(`eval $(ssh-agent -sa /tmp/coolify-ssh-agent.pid)`)
|
|
||||||
console.log({stdout,stderr})
|
|
||||||
|
|
||||||
} catch(error) {
|
|
||||||
console.log({error})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
await asyncExecShell(`SSH_AUTH_SOCK=/tmp/coolify-ssh-agent.pid ssh-add -q ${sshKeyFile}`)
|
await asyncExecShell(`SSH_AUTH_SOCK=/tmp/coolify-ssh-agent.pid ssh-add -q ${sshKeyFile}`)
|
||||||
|
|
||||||
@ -1365,6 +1359,7 @@ export function makeLabelForServices(type) {
|
|||||||
}
|
}
|
||||||
export function errorHandler({ status = 500, message = 'Unknown error.' }: { status: number, message: string | any }) {
|
export function errorHandler({ status = 500, message = 'Unknown error.' }: { status: number, message: string | any }) {
|
||||||
if (message.message) message = message.message
|
if (message.message) message = message.message
|
||||||
|
console.log({ status, message })
|
||||||
throw { status, message };
|
throw { status, message };
|
||||||
}
|
}
|
||||||
export async function generateSshKeyPair(): Promise<{ publicKey: string; privateKey: string }> {
|
export async function generateSshKeyPair(): Promise<{ publicKey: string; privateKey: string }> {
|
||||||
|
@ -205,7 +205,7 @@ export async function assignSSHKey(request: FastifyRequest) {
|
|||||||
return errorHandler({ status, message })
|
return errorHandler({ status, message })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export async function verifyRemoteDockerEngine(request: FastifyRequest, reply: FastifyReply) {
|
export async function verifyRemoteDockerEngine(request: FastifyRequest<OnlyId>, reply: FastifyReply) {
|
||||||
try {
|
try {
|
||||||
const { id } = request.params;
|
const { id } = request.params;
|
||||||
await createRemoteEngineConfiguration(id);
|
await createRemoteEngineConfiguration(id);
|
||||||
@ -217,14 +217,12 @@ export async function verifyRemoteDockerEngine(request: FastifyRequest, reply: F
|
|||||||
if (!stdout) {
|
if (!stdout) {
|
||||||
await asyncExecShell(`DOCKER_HOST=${host} docker network create --attachable ${network}`);
|
await asyncExecShell(`DOCKER_HOST=${host} docker network create --attachable ${network}`);
|
||||||
}
|
}
|
||||||
const { stdout:coolifyNetwork } = await asyncExecShell(`DOCKER_HOST=${host} docker network ls --filter 'name=coolify-infra' --no-trunc --format "{{json .}}"`);
|
const { stdout: coolifyNetwork } = await asyncExecShell(`DOCKER_HOST=${host} docker network ls --filter 'name=coolify-infra' --no-trunc --format "{{json .}}"`);
|
||||||
|
|
||||||
if (!coolifyNetwork) {
|
if (!coolifyNetwork) {
|
||||||
await asyncExecShell(`DOCKER_HOST=${host} docker network create --attachable coolify-infra`);
|
await asyncExecShell(`DOCKER_HOST=${host} docker network create --attachable coolify-infra`);
|
||||||
}
|
}
|
||||||
if (isCoolifyProxyUsed) {
|
|
||||||
await startTraefikProxy(id);
|
|
||||||
}
|
|
||||||
await prisma.destinationDocker.update({ where: { id }, data: { remoteVerified: true } })
|
await prisma.destinationDocker.update({ where: { id }, data: { remoteVerified: true } })
|
||||||
return reply.code(201).send()
|
return reply.code(201).send()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user