From 02f218389b2eaed8459fc44303756beffe23b175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B0=D1=88=D0=BA=D0=B0724=D0=B0=D1=8F?= Date: Sat, 11 Mar 2023 20:21:32 +1100 Subject: [PATCH] support listening on unix sockets --- src/services/port.js | 2 +- src/www | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/services/port.js b/src/services/port.js index 559385644..bba42b7c7 100644 --- a/src/services/port.js +++ b/src/services/port.js @@ -6,7 +6,7 @@ const dataDir = require('./data_dir'); function parseAndValidate(portStr, source) { const portNum = parseInt(portStr); - if (!portNum || portNum < 0 || portNum >= 65536) { + if (!portNum && portNum !== 0 || portNum < 0 || portNum >= 65536) { console.log(`FATAL ERROR: Invalid port value "${portStr}" from ${source}, should be a number between 0 and 65536.`); process.exit(-1); } diff --git a/src/www b/src/www index 778197e37..16989404b 100644 --- a/src/www +++ b/src/www @@ -100,7 +100,11 @@ async function startTrilium() { */ httpServer.keepAliveTimeout = 120000 * 5; - httpServer.listen(port, host); + if (port !== 0) { + httpServer.listen(port, host); // TCP socket. + } else { + httpServer.listen(host); // Unix socket. + } httpServer.on('error', error => { if (error.syscall !== 'listen') { throw error;