/
githubmirror
/
pm2
Обзор
Документация
Войти
/
githubmirror
/
pm2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/treekill/app.js
34 строки
745 B
Unitech
treekill examples
29 дек 2017, 02:22
29 дек 2017, 02:22
bb66425
Код
Авторство
О чём код?
const spawn = require('child_process').spawn var fs = require('fs'); setTimeout(function() { daemonize('pm2 ls --watch'); // setTimeout(function() { // process.exit(0); // }, 300); setInterval(function() {}, 1000); }, 3000); var daemonize = function exec (cmd, cb) { const args = cmd.split(' ') const bin = args.shift() var logFile = '/tmp/test.log'; const fdOut = fs.openSync(logFile, 'a+') const fdErr = fs.openSync(logFile, 'a+') console.log(`Spawning command ${cmd}`) console.log(`Log file: ${logFile}`) const installInstance = spawn(bin, args, { env: process.env, detached: true, stdio: ['ignore', fdOut, fdErr] }) installInstance.unref() if (typeof cb === 'function') { cb() } }