it('should read timing data', function* () { let json = readJson(path.join(baseDir, `run/agent_timing_${process.pid}.json`)); assert(json.length === 41); assert(json[1].name === 'Application Start'); assert(json[0].pid === process.pid); json = readJson(path.join(baseDir, `run/application_timing_${process.pid}.json`)); assert(json.length === 63); assert(json[1].name === 'Application Start'); assert(json[0].pid === process.pid); });
/** * Get default NodeID (computerName) * * @returns */ getNodeID() { return os.hostname().toLowerCase() + "-" + process.pid; }
describe("Test utils.getNodeID", () => { let os = require("os"); it("should give the computer hostname", () => { expect(utils.getNodeID()).toBe(os.hostname().toLowerCase() + "-" + process.pid); }); });
dumpTiming() { try { const json = this.timing.toJSON(); const rundir = this.config.rundir; const dumpFile = path.join(rundir, `${this.type}_timing_${process.pid}.json`); fs.writeFileSync(dumpFile, CircularJSON.stringify(json, null, 2)); this.timing.clear(); this.timing.disable(); } catch (err) { this.coreLogger.warn(`dumpTiming error: ${err.message}`); } }
app.messenger.on('egg-ready', () => { app.messenger.broadcast('broadcast', { from: 'app', pid: process.pid, }); });
const getProcessInfo = () => { return { pid: process.pid, memory: process.memoryUsage(), uptime: process.uptime(), argv: process.argv }; }
constructor() { super(); this.pid = String(process.pid); // pids of agent or app maneged by master // - retrieve app worker pids when it's an agent worker // - retrieve agent worker pids when it's an app worker this.opids = []; this.on('egg-pids', pids => { this.opids = pids; }); this._onMessage = this._onMessage.bind(this); process.on('message', this._onMessage); }
this.screen.key("C-c", () => { process.kill(process.pid, "SIGINT"); });
constructor(frontend) { process.title = 'ndb/ndd_service'; this._disconnectPromise = new Promise(resolve => process.once('disconnect', () => resolve(DebugState.PROCESS_DISCONNECT))); this._connected = new Set(); this._frontend = frontend; const pipePrefix = process.platform === 'win32' ? '\\\\.\\pipe\\' : os.tmpdir(); const pipeName = `node-ndb.${process.pid}.sock`; this._pipe = path.join(pipePrefix, pipeName); const server = net.createServer(socket => { socket.on('data', async d => { const runSession = await this._startSession(JSON.parse(d), frontend); socket.write('run'); runSession(); }); socket.on('error', e => caughtErrorDebug(e)); }).listen(this._pipe); server.unref(); }
app.messenger.on('egg-ready', () => { app.messenger.on('app-to-agent', function(msg) { console.log('[app] app-to-agent', msg); }); app.messenger.on('agent-to-app', function(msg) { console.log('[app] agent-to-app', msg); }); app.messenger.send('app-to-agent', 'app msg'); app.messenger.send('pid', process.pid); app.messenger.send('ready'); });
/** * send message to the specified process * Notice: in single process mode, it only can send to self process, * and it will send to both agent and app's messengers. * @param {String} pid - the process id of the receiver * @param {String} action - message key * @param {Object} data - message value * @return {Messenger} this */ sendTo(pid, action, data) { debug('[%s] send %s with %j to %s', this.pid, action, data, pid); if (pid !== process.pid) return this; this.send(action, data, 'both'); return this; }
app.messenger.on('agent2app', () => console.log('%s=%s', process.pid, count++));
agent.messenger.on('egg-ready', () => { agent.messenger.broadcast('broadcast', { from: 'agent', pid: process.pid, }); });