Merge branch 'winston' of https://github.com/M2Ys4U/KiwiIRC into winston
[KiwiIRC.git] / server / server.js
index c7e39e54202e060e8438816aac41b16622a9ee25..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
@@ -45,9 +61,9 @@ switch (process.argv[2]) {
         break;\r
 \r
     case 'build':\r
-        require('../client/assets/src/build.js');\r
+        require('../client/build.js');\r
         break;\r
-        \r
+\r
     default:\r
-        console.log('Usage: [-f|start|stop|restart|status|reconfig|build]');\r
-}
\ No newline at end of file
+        console.log('Usage: [-f|start|stop|restart|status|reconfig|build [-c <config file>] [-p <pid file>]]');\r
+}\r