From aec7d534141e66d69f83bbd4f150821b047ff038 Mon Sep 17 00:00:00 2001 From: Aya Morisawa Date: Fri, 13 Jul 2018 23:25:32 +0900 Subject: Fix port cehcking --- src/index.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/index.ts b/src/index.ts index a700441ea5..c5f5d32e57 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,7 +8,7 @@ import * as os from 'os'; import * as cluster from 'cluster'; import * as debug from 'debug'; import chalk from 'chalk'; -// import portUsed = require('tcp-port-used'); +import * as portscanner from 'portscanner'; import isRoot = require('is-root'); import Xev from 'xev'; @@ -125,12 +125,9 @@ async function init(): Promise { throw 'You need root privileges to listen on port below 1024 on Linux'; } - // Check if a port is being used - /* https://github.com/stdarg/tcp-port-used/issues/3 - if (await portUsed.check(config.port)) { - throw `Port ${config.port} is already used`; + if (await portscanner.checkPortStatus(config.port, '127.0.0.1') === 'open') { + throw `Port ${config.port} is already in use`; } - */ // Try to connect to MongoDB const mongoDBLogger = new Logger('MongoDB'); -- cgit v1.2.3-freya