Merge branch 'winston' of https://github.com/M2Ys4U/KiwiIRC into winston
[KiwiIRC.git] / server / server.js
index 3399db0def8914a5ecfc03276d660de2a5adca1b..4bb95e5cf7b591dc7ec68700297c0478e1005e61 100644 (file)
@@ -1,10 +1,26 @@
 var kiwi_app = './kiwi.js';\r
+var pidfile = '../kiwiirc.pid';\r
+var pidfile_arg;\r
+\r
+// Check if a pidfile has been set as an argument\r
+if (process.argv.indexOf('-p') > -1) {\r
+    pidfile_arg = process.argv[process.argv.indexOf('-p') + 1];\r
+\r
+    if (pidfile_arg) {\r
+        // Don't set the relative path if we have an absolute path given to us\r
+        if (['/', '\\', '.'].indexOf(pidfile_arg[0]) === -1) {\r
+            pidfile = '../' + pidfile_arg;\r
+        } else {\r
+            pidfile = pidfile_arg;\r
+        }\r
+    }\r
+}\r
 \r
 \r
 var daemon = require('daemonize2').setup({\r
     main: kiwi_app,\r
     name: 'kiwiirc',\r
-    pidfile: '../kiwiirc.pid'\r
+    pidfile: pidfile\r
 });\r
 \r
 switch (process.argv[2]) {\r
@@ -47,7 +63,7 @@ switch (process.argv[2]) {
     case 'build':\r
         require('../client/build.js');\r
         break;\r
-        \r
+\r
     default:\r
-        console.log('Usage: [-f|start|stop|restart|status|reconfig|build [-c <config file>]]');\r
+        console.log('Usage: [-f|start|stop|restart|status|reconfig|build [-c <config file>] [-p <pid file>]]');\r
 }\r