MCPcopy
hub / github.com/Unitech/pm2 / startRPC

Method startRPC

modules/pm2-io-agent/src/InteractorDaemon.js:117–147  ·  view source on GitHub ↗

* Start a RPC server and expose it throught a socket file

(opts)

Source from the content-addressed store, hash-verified

115 * Start a RPC server and expose it throught a socket file
116 */
117 startRPC (opts) {
118 log('Launching Interactor RPC server (bind to %s)', cst.INTERACTOR_RPC_PORT)
119 const rep = axon.socket('rep')
120 const rpcServer = new rpc.Server(rep)
121 const self = this
122 rep.bind(cst.INTERACTOR_RPC_PORT)
123
124 rpcServer.expose({
125 kill: function (cb) {
126 log('Shutdown request received via RPC')
127 return self.exit(null, cb)
128 },
129 getInfos: function (cb) {
130 if (self.opts && self.DAEMON_ACTIVE === true) {
131 return cb(null, {
132 machine_name: self.opts.MACHINE_NAME,
133 public_key: self.opts.PUBLIC_KEY,
134 secret_key: self.opts.SECRET_KEY,
135 remote_host: self.km_data.endpoints.web,
136 connected: self.transport.isConnected(),
137 transporters: self.transport.getActiveTransporters(),
138 socket_path: cst.INTERACTOR_RPC_PORT,
139 pm2_home_monitored: cst.PM2_HOME
140 })
141 } else {
142 return cb(null)
143 }
144 }
145 })
146 return rpcServer
147 }
148
149 /**
150 * Handle specific signals to launch memory / cpu profiling

Callers 2

startMethod · 0.95

Calls 5

cbFunction · 0.85
getActiveTransportersMethod · 0.80
bindMethod · 0.65
exitMethod · 0.65
isConnectedMethod · 0.45

Tested by

no test coverage detected