Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const childProcess = require('child_process');
  2.  
  3. let maxExec = 5;
  4.  
  5. function execProcess(command) { // Запуск внешней команды
  6.     childProcess.exec(command, function(error, stdout, stderr) {
  7.         //console.log('stdout: ' + stdout);
  8.         //console.log('stderr: ' + stderr);
  9.         if (error !== null) {
  10.             console.log('error: ' + error);
  11.         }
  12.     })
  13. }
  14.  
  15. currentCountProc = execProcess('ps aux | grep -c web.js');
  16.  
  17. if (currentCountProc < maxExec + 1) {
  18.     for (let i = 0; i < maxExec - currentCountProc; i++) {
  19.         execProcess('node ./web.js');
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement