From 7735c462c0ed8a41027a0b983c900ce3193bf3ad Mon Sep 17 00:00:00 2001 From: Darren Date: Mon, 24 Mar 2014 08:59:19 +0000 Subject: [PATCH] Custom pidfile fix --- server/server.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/server/server.js b/server/server.js index 9f3d49b..4bb95e5 100644 --- a/server/server.js +++ b/server/server.js @@ -1,17 +1,22 @@ var kiwi_app = './kiwi.js'; var pidfile = '../kiwiirc.pid'; +var pidfile_arg; // Check if a pidfile has been set as an argument -var pidfile_arg = process.argv[process.argv.indexOf('-p') + 1]; -if (pidfile_arg) { - // Don't set the relative path if we have an absolute path given to us - if (['/', '\\', '.'].indexOf(pidfile_arg[0]) === -1) { - pidfile = '../' + pidfile_arg; - } else { - pidfile = pidfile_arg; +if (process.argv.indexOf('-p') > -1) { + pidfile_arg = process.argv[process.argv.indexOf('-p') + 1]; + + if (pidfile_arg) { + // Don't set the relative path if we have an absolute path given to us + if (['/', '\\', '.'].indexOf(pidfile_arg[0]) === -1) { + pidfile = '../' + pidfile_arg; + } else { + pidfile = pidfile_arg; + } } } + var daemon = require('daemonize2').setup({ main: kiwi_app, name: 'kiwiirc', -- 2.25.1