diff --git a/README.windows.md b/README.windows.md new file mode 100644 index 000000000..d5692b2cc --- /dev/null +++ b/README.windows.md @@ -0,0 +1,47 @@ +# Installation for Windows +- Install git and Unix tools. You need sh.exe to start the scripts. +- Edit the config.json and add "ps_monitor_cmd" key to get process status: +``` +"ps_monitor_cmd": "cscript.exe bin\\win_ps.wsf //nologo" +``` +- Edit setup.json and change the "common" to copy instead of symbolic link. +``` +"common": [ + [ "copyCompress", "node_modules/jquery/dist/jquery.min.js", "htdocs/js/external/" ], + [ "copyCompress", "node_modules/jquery/dist/jquery.min.map", "htdocs/js/external/" ], + [ "copyCompress", "node_modules/zxcvbn/dist/zxcvbn.js", "htdocs/js/external/" ], + [ "copyCompress", "node_modules/zxcvbn/dist/zxcvbn.js.map", "htdocs/js/external/" ], + [ "copyCompress", "node_modules/chart.js/dist/Chart.min.js", "htdocs/js/external/" ], + + [ "copyCompress", "node_modules/font-awesome/css/font-awesome.min.css", "htdocs/css/" ], + [ "copyCompress", "node_modules/font-awesome/css/font-awesome.css.map", "htdocs/css/" ], + [ "copyFiles", "node_modules/font-awesome/fonts/*", "htdocs/fonts/" ], + + [ "copyCompress", "node_modules/mdi/css/materialdesignicons.min.css", "htdocs/css/" ], + [ "copyCompress", "node_modules/mdi/css/materialdesignicons.min.css.map", "htdocs/css/" ], + [ "copyFiles", "node_modules/mdi/fonts/*", "htdocs/fonts/" ], + + [ "copyCompress", "node_modules/moment/min/moment.min.js", "htdocs/js/external/" ], + [ "copyCompress", "node_modules/moment-timezone/builds/moment-timezone-with-data.min.js", "htdocs/js/external/" ], + [ "copyCompress", "node_modules/jstimezonedetect/dist/jstz.min.js", "htdocs/js/external/" ], + + [ "copyFiles", "node_modules/pixl-webapp/js/*", "htdocs/js/common" ], + [ "copyFile", "node_modules/pixl-webapp/css/base.css", "htdocs/css/" ], + [ "copyFiles", "node_modules/pixl-webapp/fonts/*", "htdocs/fonts/" ], + + [ "chmodFiles", "755", "bin/*" ] + ] +``` +- Create the npm installation by going to command line of source files: + +``` +cd /d my_cronicle_dir +npm install +node bin/build.js dist +sh bin/control.sh setup +sh bin/control.sh start +``` + +## Gotchas +- I've tested windows changes for simple events. If you have user switching or detached tasks, they probably will not work. +- The gid and uid returned from Process is hard-coded as windows doesn't support this. \ No newline at end of file diff --git a/bin/control.sh b/bin/control.sh index 50ef9e234..9f0f1d9d4 100755 --- a/bin/control.sh +++ b/bin/control.sh @@ -23,6 +23,9 @@ NAME="Cronicle Daemon" # # home directory SCRIPT=`perl -MCwd -le 'print Cwd::abs_path(shift)' "$0"` +if [ $? -ne 0 ]; then + SCRIPT=$(cd "$(dirname "$0")"; pwd) +fi DIR=`dirname $SCRIPT` HOMEDIR=`dirname $DIR` cd $HOMEDIR diff --git a/bin/debug.sh b/bin/debug.sh index 189b53c85..31661640d 100755 --- a/bin/debug.sh +++ b/bin/debug.sh @@ -5,6 +5,9 @@ # Add --master to force instant master on startup SCRIPT=`perl -MCwd -le 'print Cwd::abs_path(shift)' "$0"` +if [ $? -ne 0 ]; then + SCRIPT=$(cd "$(dirname "$0")"; pwd) +fi DIR=`dirname $SCRIPT` HOMEDIR=`dirname $DIR` diff --git a/bin/shell-plugin.js b/bin/shell-plugin.js index 0f1fbaeb5..bd2a0c887 100755 --- a/bin/shell-plugin.js +++ b/bin/shell-plugin.js @@ -19,10 +19,15 @@ process.stdout.setEncoding('utf8'); var stream = new JSONStream( process.stdin, process.stdout ); stream.on('json', function(job) { // got job from parent - var script_file = path.join( os.tmpdir(), 'cronicle-script-temp-' + job.id + '.sh' ); + var iswin = process.platform === "win32"; + var script_file = path.join( os.tmpdir(), 'cronicle-script-temp-' + job.id + (iswin ? '.bat' : '.sh') ); fs.writeFileSync( script_file, job.params.script, { mode: "775" } ); - var child = cp.spawn( script_file, [], { + var child = null; + if(!iswin) child = cp.spawn( script_file, [], { + stdio: ['pipe', 'pipe', 'pipe'] + } ); + else child = cp.spawn( "cmd.exe", ["/c", script_file], { stdio: ['pipe', 'pipe', 'pipe'] } ); diff --git a/bin/win_ps.wsf b/bin/win_ps.wsf new file mode 100644 index 000000000..38c919665 --- /dev/null +++ b/bin/win_ps.wsf @@ -0,0 +1,24 @@ + + + \ No newline at end of file diff --git a/lib/job.js b/lib/job.js index 02d55f24e..869bb66f8 100644 --- a/lib/job.js +++ b/lib/job.js @@ -570,7 +570,10 @@ module.exports = Class.create({ // spawn child try { - child = cp.spawn( child_cmd, child_args, child_opts ); + //Do not pass child_opts to spawn in windows, you will get + //error: "Operation not supported on socket (spawn ENOTSUP)" + child = process.platform === "win32" ? cp.spawn( "node.exe", [child_cmd.concat(child_args)], {stdio: child_opts.stdio} ) + : cp.spawn( child_cmd, child_args, child_opts ); } catch (err) { if (worker.log_fd) { fs.closeSync(worker.log_fd); worker.log_fd = null; } diff --git a/lib/main.js b/lib/main.js index b6664097b..6d7e13bda 100755 --- a/lib/main.js +++ b/lib/main.js @@ -29,4 +29,8 @@ var server = new PixlServer({ server.startup( function() { // server startup complete process.title = server.__name + ' Server'; + + //Windows support + if(!process.getgid) process.getgid = function() { return 100;}; + if(!process.getuid) process.getuid = function() { return -1; } } );