Skip to content

Commit

Permalink
Windows support
Browse files Browse the repository at this point in the history
  • Loading branch information
dropthemic committed Jun 10, 2018
1 parent 67ad0f6 commit a772227
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
9 changes: 7 additions & 2 deletions bin/shell-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']
} );

Expand Down
4 changes: 3 additions & 1 deletion lib/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,9 @@ 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 = cp.spawn( "node.exe", [child_cmd.concat(child_args)], {stdio: child_opts.stdio} );
}
catch (err) {
if (worker.log_fd) { fs.closeSync(worker.log_fd); worker.log_fd = null; }
Expand Down
4 changes: 4 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
} );

0 comments on commit a772227

Please sign in to comment.