This commit is contained in:
Andras Bacsai 2022-03-01 00:12:54 +01:00
parent 69d1556a1d
commit 0325343ede

View File

@ -65,6 +65,12 @@ backend {{domain}}
option forwardfor option forwardfor
server {{id}} {{id}}:{{port}} server {{id}} {{id}}:{{port}}
{{/applications}} {{/applications}}
{{#services}}
backend {{domain}}
option forwardfor
server {{id}} {{id}}:{{port}}
{{/services}}
`; `;
export async function haproxyInstance() { export async function haproxyInstance() {
const { proxyPassword } = await db.listSettings(); const { proxyPassword } = await db.listSettings();
@ -108,10 +114,33 @@ export async function configureHAProxy() {
}); });
} }
} }
// const services = await db.prisma.service.findMany({
// include: {
// destinationDocker: true,
// minio: true,
// plausibleAnalytics: true,
// vscodeserver: true,
// wordpress: true
// }
// });
// for (const service of services) {
// const {
// fqdn,
// id,
// type,
// destinationDocker: { engine }
// } = service;
// const found = db.supportedServiceTypesAndVersions.find((a) => a.name === type);
// if (found) {
// const port = found.ports.main;
// const publicPort = service[type]?.publicPort;
// const isRunning = await checkContainer(engine, id);
// }
// }
const output = mustache.render(template, data); const output = mustache.render(template, data);
const newHash = crypto.createHash('md5').update(JSON.stringify(template)).digest('hex'); const newHash = crypto.createHash('md5').update(JSON.stringify(template)).digest('hex');
const { proxyHash, id } = await db.listSettings(); const { proxyHash, id } = await db.listSettings();
console.log(proxyHash, newHash);
if (proxyHash !== newHash) { if (proxyHash !== newHash) {
await db.prisma.setting.update({ where: { id }, data: { proxyHash: newHash } }); await db.prisma.setting.update({ where: { id }, data: { proxyHash: newHash } });
console.log('HAProxy configuration changed, updating...'); console.log('HAProxy configuration changed, updating...');