const getOsInfo = () => { return { uptime: os.uptime(), type: os.type(), release: os.release(), hostname: os.hostname(), arch: os.arch(), platform: os.platform(), user: getUserInfo() }; }
/** * @description Connect to Zwave USB driver * @param {string} driverPath - Path to the USB driver. * @example * zwave.connect(driverPath); */ function connect(driverPath) { logger.debug(`Zwave : Connecting to USB = ${driverPath}`); // special case for macOS if (os.platform() === 'darwin') { this.driverPath = driverPath.replace('/dev/tty.', '/dev/cu.'); } else { this.driverPath = driverPath; } this.ready = false; this.zwave.connect(this.driverPath); this.connected = true; }
function displayResults (results) { if (quiet === false) console.log('==========') const benchNames = Object.keys(results) for (var i = 0; i < benchNames.length; i += 1) { console.log(`${benchNames[i].toUpperCase()} benchmark averages`) const benchmark = results[benchNames[i]] const loggers = Object.keys(benchmark) for (var j = 0; j < loggers.length; j += 1) { var logger = benchmark[loggers[j]] var average = sum(logger) / logger.length console.log(`${loggers[j]} average: ${average.toFixed(3)}ms`) } } if (quiet === false) { console.log('==========') console.log( `System: ${type()}/${platform()} ${arch()} ${release()}`, `~ ${cpus()[0].model} (cores/threads: ${cpus().length})` ) } }
function runYarn(cwd, args, resolveOutput) { const isWin = os.platform() === "win32"; return new Promise((resolve, reject) => { debug("yarn", yarnPath, args, cwd); var child = fork(yarnPath, args || [], { cwd: cwd, stdio: !resolveOutput ? "inherit" : "pipe" }); if (isWin) { // a windows bug. need to press enter sometimes try { // process.stdin.write("\n"); // process.stdin.end(); } catch (e) {} } var output = ""; if (resolveOutput) { child.stdout.on("data", data => { output += data; }); } child.on("exit", code => { debug("yarn completed"); resolve(output); }); }); }
console.clear() if (os.platform() === 'win32') { cp.execFileSync('docker', ['exec', '-it', containerId, '/bin/sh', '-c', '[ -e /bin/bash ] && /bin/bash || /bin/sh'], { 'stdio': 'inherit'
hostname: os.hostname(), type: os.type(), platform: os.platform(), arch: os.arch(), release: os.release(),
/** * Bind process with cpu * * @param {String} sid server id * @param {String} pid process id * @param {String} host server host * @return {Void} */ export function bindCpu(sid: string, pid: string, host: string) { if (os.platform() === Constants.PLATFORM.LINUX && cpus[sid] !== undefined) { if (utils.isLocal(host)) { let options: string[] = []; options.push('-pc'); options.push(String(cpus[sid])); options.push(pid); localrun(Constants.COMMAND.TASKSET, null, options); } else { let cmd = util.format('taskset -pc "%s" "%s"', cpus[sid], pid); sshrun(cmd, host, null); } } }
/** * Append the default system admin modules */ export function registerDefaultModules(isMaster: boolean, app: Application, closeWatcher: boolean) { if (!closeWatcher) { if (isMaster) { app.registerAdmin(MasterWatcherModule, { app: app }); } else { app.registerAdmin(MonitorWatcherModule, { app: app }); } } app.registerAdmin(WatchServerModule, { app: app }); app.registerAdmin(ConsoleModule, { app: app, starter: starter }); if (app.enabled('systemMonitor')) { if (os.platform() !== Constants.PLATFORM.WIN) { app.registerAdmin(admin.modules.systemInfo); app.registerAdmin(admin.modules.nodeInfo); } app.registerAdmin(OnlineUserModule); app.registerAdmin(admin.modules.monitorLog, { path: pathUtil.getLogPath(app.getBase()) }); app.registerAdmin(admin.modules.scripts, { app: app, path: pathUtil.getScriptPath(app.getBase()) }); if (os.platform() !== Constants.PLATFORM.WIN) { app.registerAdmin(admin.modules.profiler); } } }
if (utils.isLocal(server.host)) { let options: string[] = []; if (os.platform() === Constants.PLATFORM.WIN) { cmd = Constants.COMMAND.TASKKILL; options.push('/pid'); localrun(cmd, null, options); } else { if (os.platform() === Constants.PLATFORM.WIN) { cmd = util.format('taskkill /pid %s /f', pids[i]); } else {
if (os.platform() === constants.PLATFORM.WIN) { exec(KILL_CMD_WIN); } else {
pause() { this.paused = true; if (this.output === '-') { this.proc.stdout.pause(); return; } if (['win32', 'win64'].includes(os.platform())) { this.proc.stdin.write('c'); } else { this.proc.kill('SIGSTOP'); } }
resume() { this.paused = false; if (this.output === '-') { this.proc.stdout.resume(); } if (['win32', 'win64'].includes(os.platform())) { this.proc.stdin.write('\n'); } else { this.proc.kill('SIGCONT'); } }
/** * @description Connect to Zwave USB driver * @param {string} driverPath - Path to the USB driver. * @example * zwave.connect(driverPath); */ function connect(driverPath) { logger.debug(`Zwave : Connecting to USB = ${driverPath}`); // special case for macOS if (os.platform() === 'darwin') { this.driverPath = driverPath.replace('/dev/tty.', '/dev/cu.'); } else { this.driverPath = driverPath; } this.ready = false; this.zwave.connect(this.driverPath); this.connected = true; }
function runYarn(cwd, args, resolveOutput) { const isWin = os.platform() === "win32"; return new Promise((resolve, reject) => { debug("yarn", yarnPath, args, cwd); var child = fork(yarnPath, args || [], { cwd: cwd, stdio: !resolveOutput ? "inherit" : "pipe" }); if (isWin) { // a windows bug. need to press enter sometimes try { // process.stdin.write("\n"); // process.stdin.end(); } catch (e) {} } var output = ""; if (resolveOutput) { child.stdout.on("data", data => { output += data; }); } child.on("exit", code => { debug("yarn completed"); resolve(output); }); }); }
hostname: os.hostname(), type: os.type(), platform: os.platform(), arch: os.arch(), release: os.release(),