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

Method dump

modules/pm2-io-agent/src/PM2Interface.js:104–138  ·  view source on GitHub ↗

* Dump current processes managed by pm2 into DUMP_FILE_PATH file * @method dump * @param {} cb * @return

(cb)

Source from the content-addressed store, hash-verified

102 * @return
103 */
104 dump (cb) {
105 var envArr = []
106
107 this.rpc.getMonitorData({}, (err, list) => {
108 if (err) {
109 return typeof cb === 'function' ? cb(err) : false
110 }
111
112 /**
113 * Description
114 * @method end
115 * @param {} err
116 * @return
117 */
118 const end = () => {
119 // Overwrite dump file, delete if broken and exit
120 try {
121 fs.writeFileSync(cst.DUMP_FILE_PATH, JSON.stringify(envArr, '', 2))
122 } catch (e) {
123 log('Dump error', e.stack || e)
124 return cb(e)
125 }
126 return (cb) ? cb(null, {success: true}) : true
127 }
128
129 async.each(list, (app, done) => {
130 delete app.pm2_env.instances
131 delete app.pm2_env.pm_id
132 if (!app.pm2_env.pmx_module) {
133 envArr.push(app.pm2_env)
134 }
135 done()
136 }, end)
137 })
138 }
139
140 _callWithProcessId (fn, params, cb) {
141 if (params.id === undefined) {

Callers 9

autoDumpMethod · 0.80
getValueFromDumpMethod · 0.80
updateMethod · 0.80
CLI.jsFile · 0.80
programmatic.jsFile · 0.80
dump.mocha.jsFile · 0.80
misc_commands.jsFile · 0.80
API.jsFile · 0.80

Calls 2

cbFunction · 0.85
doneFunction · 0.50

Tested by

no test coverage detected