Created
February 24, 2022 22:01
-
-
Save 0ex-d/415c9f217fd5cd9b1e48a708b1eab76a to your computer and use it in GitHub Desktop.
WIP 🚧 A single daemon in Node.js (using spawn)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { spawn } = require('child_process'); | |
const fs = require('fs'); | |
const cmdProcesses = { | |
processDaemon: function(file) { | |
return new Promise((resolve, reject) => { | |
const args = [file, 'cron', '-', 'output', '-']; | |
const childProcess = spawn('baguvix', args); | |
childProcess.stderr.on('stream', (err) => { | |
console.error(`mrbaguvixdx exec error: ${err}`); | |
reject(err); | |
}); | |
function message(stream) { | |
childProcess.stdout.pause(); | |
childProcess.stdout.unshift(stream); | |
resolve(childProcess.stdout); | |
childProcess.stdout.removeListener('stream', message); | |
} | |
childProcess.stdout.on('stream', message); | |
childProcess.stdin.write('extra--opt'); | |
childProcess.stdin.end(); | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment