mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: allow server to bind to Unix Domain Sockets
This commit is contained in:
committed by
Joachim Van Herwegen
parent
0eb50891ec
commit
bf0e35be37
@@ -9,18 +9,27 @@ import { Initializer } from './Initializer';
|
||||
*/
|
||||
export class ServerInitializer extends Initializer implements Finalizable {
|
||||
private readonly serverFactory: HttpServerFactory;
|
||||
private readonly port: number;
|
||||
private readonly port?: number;
|
||||
private readonly socketPath?: string;
|
||||
|
||||
private server?: Server;
|
||||
|
||||
public constructor(serverFactory: HttpServerFactory, port: number) {
|
||||
public constructor(serverFactory: HttpServerFactory, port?: number, socketPath?: string) {
|
||||
super();
|
||||
this.serverFactory = serverFactory;
|
||||
this.port = port;
|
||||
this.socketPath = socketPath;
|
||||
if (!port && !socketPath) {
|
||||
throw new Error('Either Port or Socket arguments must be set');
|
||||
}
|
||||
}
|
||||
|
||||
public async handle(): Promise<void> {
|
||||
this.server = this.serverFactory.startServer(this.port);
|
||||
if (this.socketPath) {
|
||||
this.server = this.serverFactory.startServer(this.socketPath);
|
||||
} else if (this.port) {
|
||||
this.server = this.serverFactory.startServer(this.port);
|
||||
}
|
||||
}
|
||||
|
||||
public async finalize(): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user