result.on(NPM_RESULT_CLOSE, code => { if (code === 0) { resolve(); } else if (code !== 0) { reject(); } });
run() { pp.info('Updating PhaserJS...') const npm = spawn('npm', ['install', 'phaser-ce@latest'], { cwd: paths.cli.base, stdio: ['pipe', 'ignore', 'ignore']}) npm.on('close', (e) => { if (e === 0) { fs.copySync(path.join(paths.cli.phaser, 'phaser.min.js'), path.join(paths.game_vendor, 'phaser.min.js')) pp.ok('PhaserJS Updated!') } else if (e === 243) { pp.err('Please use "sudo pnkit update"') } else { pp.err(`An error occurred during the update: code ${e}`) } }) }
ssh.on('exit', () => { if (process.argv.includes('--no-up')) return; cp.spawnSync('ssh', ['-C', host, 'docker-compose', '-f', composeFile, 'up', '-d'], { stdio: 'inherit' }); if (process.argv.includes('--no-prune')) return; cp.spawnSync('ssh', ['-C', host, 'docker', 'image', 'prune', '-a', '-f'], { stdio: 'inherit' }); });
function startElectron (config, ports) { var cmd = ''; var args = null; var debugPortsArgs = [`--debug-brk=${ports[0]}`, `--inspect-brk=${ports[1]}`]; var extraArgs = config.appArgs || []; if (OS.mac && statSync(config.electronPath).isDirectory()) { cmd = 'open'; args = ['-nW', '-a', config.electronPath, '--args'].concat(debugPortsArgs, extraArgs); } else { cmd = config.electronPath; args = debugPortsArgs.concat(extraArgs); } var proc = spawn(cmd, args, { stdio: ['ignore', 'pipe', 'pipe'] }); proc.stdout.on('data', buf => STDOUT_LOGGER(lodash.trimEnd(String(buf), '\n'))); proc.stderr.on('data', buf => STDERR_LOGGER(lodash.trimEnd(String(buf), '\n'))); }
start() { let cmd = 'tcpdump'; let args = ['-nvvv', '-l', '-i', 'eth0', 'icmp', 'and', 'icmp[icmptype]=icmp-echo']; this.tcpdumpProcess = spawn(cmd, args, {stdio: ['ignore', 'pipe', 'ignore']}); this.tcpdumpProcess.on('error', (err) => { console.log(chalk.bgYellow.bold('Warning:') + ' Cannot spawn tcpdump. Error code: ' + err.code); }); this.tcpdumpProcess.stdout.on('data', (data) => { let echo_request = data.toString(); let lines = echo_request.split("\n"); if (lines[1] === undefined) return; let ip_address = lines[1].split(">")[0]; if (ip_address === undefined || ip_address.length === 0) return; else ip_address = ip_address.trim(); this.emit('data', { 'ip': ip_address, 'service': 'ping', 'request': 'ICMP echo request from ' + ip_address, 'request_headers': echo_request }); }); }
unpackToServer(next) { this.logger.debug('Unpacking pack to server.'); const Exec = Process.spawn('tar', ['-xzf', Path.basename(this.archiveLocation), '-C', this.server.path()], { cwd: Path.dirname(this.archiveLocation), stdio: ['ignore', 'ignore', 'pipe'], }); const stderrLines = []; Exec.stderr.setEncoding('utf8'); Exec.stderr.on('data', data => stderrLines.push(data)); Exec.on('error', execErr => { this.logger.error({ location: this.archiveLocation }, execErr); return next(new Error('There was an error while attempting to decompress this file.')); }); Exec.on('exit', (code, signal) => { if (code !== 0) { this.logger.error({ location: this.archiveLocation, code, signal }, `Failed to decompress server pack archive: ${stderrLines.join('\n')}`); } return next(); }); }
dockerProcess.on("close", (code) => { fse.removeSync(dockerContextDir); if (code === 0 && argv.push) { if (tags.length === 0) { console.error("Can not push an image without a tag."); process.exit(1); } // Stop if there's a code !== 0 tags.every((tag) => { const process = childProcess.spawnSync( "docker", ["push", tag], { stdio: "inherit" } ); code = process.status; return code === 0; }); } process.exit(code); });
child.kill() child.stdout.setEncoding("utf-8") child.stdout.on("data", function (data) { output += data }) child.on(name, function (code, signal) { if (signal == null) return resolve(code) return reject( child.on("error", reject) child.stdout.on("error", reject) child.stdout.on("end", resolve) }), listen("close"),
}) cp.once('error', function onError (err) { bridge.logger.error(`Process(${cp.pid}) Unexpected error on child process '${appDir}'`, err.message, err.stack) cp.kill('SIGKILL') }) cp.once('exit', (code, signal) => { bridge.logger.info(`Process(${cp.pid}) exited with code ${code}, signal ${signal}`) bridge.didExit(code, signal) }) exit: (force, gcore) => { if (force) { bridge.logger.info(`force stop process(${cp.pid}).`) cp.kill('SIGKILL') return bridge.logger.info(`abort process(${cp.pid}).`) cp.kill('SIGABRT') return bridge.logger.info(`Process(${cp.pid}) end of life, killing process after 1s.`) setTimeout(() => cp.kill(), 1000) return cp.pid })
}); console.log(`[INFO] Executed: '${command}'`); cp.once('close', code => { if (code > 0) { console.log(`[ERROR] '${command}' Exited with code ${code}`);
result.on(NPM_RESULT_CLOSE, code => { if (code === 0) { resolve(); } else if (code !== 0) { reject(); } });