* Usefull when custom PM2 created with independent flag set to true * This will cleanup the newly created instance * by removing folder, killing PM2 and so on * * @param {Function} cb callback once cleanup is successfull
(cb)
| 196 | * @param {Function} cb callback once cleanup is successfull |
| 197 | */ |
| 198 | destroy (cb) { |
| 199 | var that = this; |
| 200 | |
| 201 | debug('Killing and deleting current deamon'); |
| 202 | |
| 203 | this.killDaemon(function() { |
| 204 | var cmd = 'rm -rf ' + that.pm2_home; |
| 205 | var test_path = path.join(that.pm2_home, 'module_conf.json'); |
| 206 | var test_path_2 = path.join(that.pm2_home, 'pm2.pid'); |
| 207 | |
| 208 | if (that.pm2_home.indexOf('.pm2') > -1) |
| 209 | return cb(new Error('Destroy is not a allowed method on .pm2')); |
| 210 | |
| 211 | fs.access(test_path, fs.constants.R_OK, function(err) { |
| 212 | if (err) return cb(err); |
| 213 | debug('Deleting temporary folder %s', that.pm2_home); |
| 214 | sexec(cmd, cb); |
| 215 | }); |
| 216 | }); |
| 217 | } |
| 218 | |
| 219 | /** |
| 220 | * Disconnect from PM2 instance |
nothing calls this directly
no test coverage detected