feat: allow server to bind to Unix Domain Sockets

This commit is contained in:
Koen Luyten
2022-11-17 16:57:20 +01:00
committed by Joachim Van Herwegen
parent 0eb50891ec
commit bf0e35be37
15 changed files with 186 additions and 14 deletions

View File

@@ -33,6 +33,11 @@ const portNames = [
'BaseHttpServerFactory',
] as const;
const socketNames = [
// Unit
'BaseHttpServerFactory',
];
export function getPort(name: typeof portNames[number]): number {
const idx = portNames.indexOf(name);
// Just in case something doesn't listen to the typings
@@ -42,6 +47,15 @@ export function getPort(name: typeof portNames[number]): number {
return 6000 + idx;
}
export function getSocket(name: typeof socketNames[number]): string {
const idx = socketNames.indexOf(name);
// Just in case something doesn't listen to the typings
if (idx < 0) {
throw new Error(`Unknown socket name ${name}`);
}
return `css${idx}.sock`;
}
export function describeIf(envFlag: string): Describe {
const flag = `TEST_${envFlag.toUpperCase()}`;
const enabled = !/^(|0|false)$/iu.test(process.env[flag] ?? '');