Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const childProcess = require('child_process');
- let maxExec = 5;
- function execProcess(command) { // Запуск внешней команды
- childProcess.exec(command, function(error, stdout, stderr) {
- //console.log('stdout: ' + stdout);
- //console.log('stderr: ' + stderr);
- if (error !== null) {
- console.log('error: ' + error);
- }
- })
- }
- currentCountProc = execProcess('ps aux | grep -c web.js');
- if (currentCountProc < maxExec + 1) {
- for (let i = 0; i < maxExec - currentCountProc; i++) {
- execProcess('node ./web.js');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement