From 98a313469200907f6e76549771c927941ce86936 Mon Sep 17 00:00:00 2001 From: Darren Date: Mon, 24 Mar 2014 07:33:54 +0000 Subject: [PATCH] Custom pidfile location --- server/server.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/server/server.js b/server/server.js index 3399db0..9f3d49b 100644 --- a/server/server.js +++ b/server/server.js @@ -1,10 +1,21 @@ var kiwi_app = './kiwi.js'; +var pidfile = '../kiwiirc.pid'; +// 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; + } +} var daemon = require('daemonize2').setup({ main: kiwi_app, name: 'kiwiirc', - pidfile: '../kiwiirc.pid' + pidfile: pidfile }); switch (process.argv[2]) { @@ -47,7 +58,7 @@ switch (process.argv[2]) { case 'build': require('../client/build.js'); break; - + default: - console.log('Usage: [-f|start|stop|restart|status|reconfig|build [-c ]]'); + console.log('Usage: [-f|start|stop|restart|status|reconfig|build [-c ] [-p ]]'); } -- 2.25.1