Built motion from commit (unavailable).|2.3.3
[motion2.git] / server / api / pm2 / pm2.controller.js
index 08cc507..6b0e97d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x122f=['error','stack','name','status','send','npm\x20install','info','index','list','reject','length','catch','params','then','create','body','script','../../files/plugins','chdir','dirname','dump','Missing\x20name\x20and/or\x20path','update','restart','hasOwnProperty','Unknown\x20status','destroy','delete','Unknown\x20id','lodash','../../config/pm2','../../config/logger','path','child_process','sendStatus','json'];(function(_0x3b18e6,_0x35e310){var _0xaf05b7=function(_0x5f0cc8){while(--_0x5f0cc8){_0x3b18e6['push'](_0x3b18e6['shift']());}};_0xaf05b7(++_0x35e310);}(_0x122f,0xd1));var _0xf122=function(_0xf46bd9,_0x322826){_0xf46bd9=_0xf46bd9-0x0;var _0x2763c3=_0x122f[_0xf46bd9];return _0x2763c3;};'use strict';var _=require(_0xf122('0x0'));var pm2=require(_0xf122('0x1'));var logger=require(_0xf122('0x2'))('api');var path=require(_0xf122('0x3'));var exec=require(_0xf122('0x4'))['exec'];var BPromise=require('bluebird');function handleEntityNotFound(_0x182b6a,_0x2a38e7){return function(_0x4b39eb){if(!_0x4b39eb){_0x182b6a[_0xf122('0x5')](0x194);;}return _0x4b39eb;};}function respondWithResult(_0x142216,_0x47f78b){_0x47f78b=_0x47f78b||0xc8;return function(_0x5a00b0){if(_0x5a00b0){return _0x142216['status'](_0x47f78b)[_0xf122('0x6')](_0x5a00b0);}return null;};}function handleError(_0x1ec5fa,_0x44f63f){_0x44f63f=_0x44f63f||0x1f4;return function(_0x2f1357){logger[_0xf122('0x7')](_0x2f1357[_0xf122('0x8')]);if(_0x2f1357[_0xf122('0x9')]){delete _0x2f1357['name'];}_0x1ec5fa[_0xf122('0xa')](_0x44f63f)[_0xf122('0xb')](_0x2f1357);};}function execChildProcess(){return new BPromise(function(_0x5564ba,_0xb18cd6){exec(_0xf122('0xc'),function(_0x36751a,_0x3a5ef0,_0x15f085){logger['info'](_0x3a5ef0);logger[_0xf122('0xd')](_0x15f085);if(_0x36751a){logger['error'](_0x36751a);return _0xb18cd6(_0x36751a);}return _0x5564ba(_0x3a5ef0);});});}exports[_0xf122('0xe')]=function(_0x716ae7,_0x4a2242){return pm2[_0xf122('0xf')]()['then'](function(_0x186d81){if(_0x186d81){var _0x1a6524=_[_0xf122('0x10')](_0x186d81,function(_0x22d688){return _0x22d688[_0xf122('0x9')]==='express'||_0x22d688[_0xf122('0x9')]==='motion2';});return{'rows':_0x1a6524,'count':_0x1a6524[_0xf122('0x11')]};}return null;})['then'](respondWithResult(_0x4a2242,null))[_0xf122('0x12')](handleError(_0x4a2242,null));};exports['show']=function(_0x28f309,_0x5713ac){return pm2['describe'](_0x28f309[_0xf122('0x13')]['id'])['then'](respondWithResult(_0x5713ac,null))[_0xf122('0x14')](handleEntityNotFound(_0x5713ac,null))[_0xf122('0x12')](handleError(_0x5713ac,null));};exports[_0xf122('0x15')]=function(_0x55d467,_0x4dcb9e){if(_0x55d467[_0xf122('0x16')][_0xf122('0x9')]&&_0x55d467['body'][_0xf122('0x17')]){var _0x164bf6=path['join'](__dirname,_0xf122('0x18'),_0x55d467[_0xf122('0x16')][_0xf122('0x17')]);var _0xe46ae5=process['cwd']();process[_0xf122('0x19')](path[_0xf122('0x1a')](_0x164bf6));return execChildProcess()[_0xf122('0x14')](function(_0x4d7ff4){process['chdir'](_0xe46ae5);return pm2['start']({'name':_0x55d467[_0xf122('0x16')][_0xf122('0x9')],'script':_0x164bf6});})['then'](function(_0x1ecd71){pm2[_0xf122('0x1b')]();return _0x1ecd71[0x0];})[_0xf122('0x14')](respondWithResult(_0x4dcb9e,0xc9))[_0xf122('0x12')](handleError(_0x4dcb9e,null));}else{return _0x4dcb9e[_0xf122('0xa')](0x1f4)['send']({'message':_0xf122('0x1c')});}};exports[_0xf122('0x1d')]=function(_0xd0214e,_0x139205){if(_0xd0214e[_0xf122('0x16')]['id']){delete _0xd0214e[_0xf122('0x16')]['id'];}var _0x153b6b={'online':_0xf122('0x1e'),'stopped':'stop'};if(_0x153b6b[_0xf122('0x1f')](_0xd0214e[_0xf122('0x16')][_0xf122('0xa')])){return pm2[_0x153b6b[_0xd0214e[_0xf122('0x16')][_0xf122('0xa')]]](_0xd0214e[_0xf122('0x13')]['id'])[_0xf122('0x14')](respondWithResult(_0x139205,0xc8))[_0xf122('0x12')](handleError(_0x139205,null));}else{return _0x139205[_0xf122('0xa')](0x1f4)[_0xf122('0xb')]({'message':_0xf122('0x20')});}};exports[_0xf122('0x21')]=function(_0x3b6b26,_0x42deef){if(_0x3b6b26[_0xf122('0x16')]['id']){delete _0x3b6b26['body']['id'];}if(_0x3b6b26[_0xf122('0x13')]['id']){return pm2[_0xf122('0x22')](_0x3b6b26[_0xf122('0x13')]['id'])['then'](function(_0x2c3f26){pm2[_0xf122('0x1b')]();return _0x2c3f26[0x0];})[_0xf122('0x14')](respondWithResult(_0x42deef,null))[_0xf122('0x12')](handleError(_0x42deef,null));}else{return _0x42deef[_0xf122('0xa')](0x1f4)[_0xf122('0xb')]({'message':_0xf122('0x23')});}};
\ No newline at end of file
+var _0x23bb=['Unknown\x20status','destroy','delete','Unknown\x20id','lodash','api','path','child_process','bluebird','stack','name','status','send','npm\x20install','info','error','index','list','then','reject','express','motion2','catch','show','params','create','body','script','join','../../files/plugins','cwd','chdir','start','dump','Missing\x20name\x20and/or\x20path','update','restart','stop','hasOwnProperty'];(function(_0x5834bc,_0x3d4801){var _0x3e183a=function(_0x18b023){while(--_0x18b023){_0x5834bc['push'](_0x5834bc['shift']());}};_0x3e183a(++_0x3d4801);}(_0x23bb,0x79));var _0xb23b=function(_0x40e41e,_0x3d30e7){_0x40e41e=_0x40e41e-0x0;var _0x18b70c=_0x23bb[_0x40e41e];return _0x18b70c;};'use strict';var _=require(_0xb23b('0x0'));var pm2=require('../../config/pm2');var logger=require('../../config/logger')(_0xb23b('0x1'));var path=require(_0xb23b('0x2'));var exec=require(_0xb23b('0x3'))['exec'];var BPromise=require(_0xb23b('0x4'));function handleEntityNotFound(_0xe2b77c,_0x38419d){return function(_0x58bf2a){if(!_0x58bf2a){_0xe2b77c['sendStatus'](0x194);;}return _0x58bf2a;};}function respondWithResult(_0x50f8a8,_0x306f8b){_0x306f8b=_0x306f8b||0xc8;return function(_0x4c5626){if(_0x4c5626){return _0x50f8a8['status'](_0x306f8b)['json'](_0x4c5626);}return null;};}function handleError(_0x29e8e9,_0x4d00fe){_0x4d00fe=_0x4d00fe||0x1f4;return function(_0x117bd5){logger['error'](_0x117bd5[_0xb23b('0x5')]);if(_0x117bd5[_0xb23b('0x6')]){delete _0x117bd5['name'];}_0x29e8e9[_0xb23b('0x7')](_0x4d00fe)[_0xb23b('0x8')](_0x117bd5);};}function execChildProcess(){return new BPromise(function(_0x56e9ba,_0x4517ca){exec(_0xb23b('0x9'),function(_0x1b5f93,_0x5cc7fd,_0x1048f2){logger[_0xb23b('0xa')](_0x5cc7fd);logger[_0xb23b('0xa')](_0x1048f2);if(_0x1b5f93){logger[_0xb23b('0xb')](_0x1b5f93);return _0x4517ca(_0x1b5f93);}return _0x56e9ba(_0x5cc7fd);});});}exports[_0xb23b('0xc')]=function(_0x2f2fb2,_0x3ee84b){return pm2[_0xb23b('0xd')]()[_0xb23b('0xe')](function(_0x2ff6e8){if(_0x2ff6e8){var _0x3ff740=_[_0xb23b('0xf')](_0x2ff6e8,function(_0x2e4897){return _0x2e4897[_0xb23b('0x6')]===_0xb23b('0x10')||_0x2e4897[_0xb23b('0x6')]===_0xb23b('0x11');});return{'rows':_0x3ff740,'count':_0x3ff740['length']};}return null;})[_0xb23b('0xe')](respondWithResult(_0x3ee84b,null))[_0xb23b('0x12')](handleError(_0x3ee84b,null));};exports[_0xb23b('0x13')]=function(_0x2d9584,_0x158e02){return pm2['describe'](_0x2d9584[_0xb23b('0x14')]['id'])['then'](respondWithResult(_0x158e02,null))[_0xb23b('0xe')](handleEntityNotFound(_0x158e02,null))[_0xb23b('0x12')](handleError(_0x158e02,null));};exports[_0xb23b('0x15')]=function(_0x5ddf16,_0x57c0df){if(_0x5ddf16[_0xb23b('0x16')][_0xb23b('0x6')]&&_0x5ddf16[_0xb23b('0x16')][_0xb23b('0x17')]){var _0x1ca831=path[_0xb23b('0x18')](__dirname,_0xb23b('0x19'),_0x5ddf16['body'][_0xb23b('0x17')]);var _0x197b14=process[_0xb23b('0x1a')]();process[_0xb23b('0x1b')](path['dirname'](_0x1ca831));return execChildProcess()[_0xb23b('0xe')](function(_0x3bec93){process['chdir'](_0x197b14);return pm2[_0xb23b('0x1c')]({'name':_0x5ddf16['body'][_0xb23b('0x6')],'script':_0x1ca831});})['then'](function(_0x3968db){pm2[_0xb23b('0x1d')]();return _0x3968db[0x0];})['then'](respondWithResult(_0x57c0df,0xc9))[_0xb23b('0x12')](handleError(_0x57c0df,null));}else{return _0x57c0df[_0xb23b('0x7')](0x1f4)[_0xb23b('0x8')]({'message':_0xb23b('0x1e')});}};exports[_0xb23b('0x1f')]=function(_0x5ebe63,_0x6c68fa){if(_0x5ebe63[_0xb23b('0x16')]['id']){delete _0x5ebe63[_0xb23b('0x16')]['id'];}var _0x35a723={'online':_0xb23b('0x20'),'stopped':_0xb23b('0x21')};if(_0x35a723[_0xb23b('0x22')](_0x5ebe63[_0xb23b('0x16')]['status'])){return pm2[_0x35a723[_0x5ebe63[_0xb23b('0x16')][_0xb23b('0x7')]]](_0x5ebe63[_0xb23b('0x14')]['id'])['then'](respondWithResult(_0x6c68fa,0xc8))[_0xb23b('0x12')](handleError(_0x6c68fa,null));}else{return _0x6c68fa[_0xb23b('0x7')](0x1f4)[_0xb23b('0x8')]({'message':_0xb23b('0x23')});}};exports[_0xb23b('0x24')]=function(_0x496a38,_0x8c65f3){if(_0x496a38[_0xb23b('0x16')]['id']){delete _0x496a38[_0xb23b('0x16')]['id'];}if(_0x496a38[_0xb23b('0x14')]['id']){return pm2[_0xb23b('0x25')](_0x496a38[_0xb23b('0x14')]['id'])[_0xb23b('0xe')](function(_0x2f0019){pm2[_0xb23b('0x1d')]();return _0x2f0019[0x0];})[_0xb23b('0xe')](respondWithResult(_0x8c65f3,null))[_0xb23b('0x12')](handleError(_0x8c65f3,null));}else{return _0x8c65f3[_0xb23b('0x7')](0x1f4)['send']({'message':_0xb23b('0x26')});}};
\ No newline at end of file