Built motion from commit (unavailable).|2.5.30
[motion2.git] / server / api / pm2 / pm2.controller.js
index 38968ff..cbe4025 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xec12=['name','status','npm\x20install','info','index','list','then','reject','express','motion2','length','catch','create','script','join','../../files/plugins','body','cwd','chdir','send','Missing\x20name\x20and/or\x20path','update','restart','hasOwnProperty','params','destroy','delete','Unknown\x20id','lodash','../../config/logger','api','path','exec','bluebird','sendStatus','json','error','stack'];(function(_0x2070da,_0x45e586){var _0x4f9fe1=function(_0x5b6f2a){while(--_0x5b6f2a){_0x2070da['push'](_0x2070da['shift']());}};_0x4f9fe1(++_0x45e586);}(_0xec12,0x172));var _0x2ec1=function(_0x401fb4,_0x104039){_0x401fb4=_0x401fb4-0x0;var _0x425b3=_0xec12[_0x401fb4];return _0x425b3;};'use strict';var _=require(_0x2ec1('0x0'));var pm2=require('../../config/pm2');var logger=require(_0x2ec1('0x1'))(_0x2ec1('0x2'));var path=require(_0x2ec1('0x3'));var exec=require('child_process')[_0x2ec1('0x4')];var BPromise=require(_0x2ec1('0x5'));function handleEntityNotFound(_0xe718ee,_0x32916f){return function(_0xf2171b){if(!_0xf2171b){_0xe718ee[_0x2ec1('0x6')](0x194);;}return _0xf2171b;};}function respondWithResult(_0x5c2465,_0xec84ce){_0xec84ce=_0xec84ce||0xc8;return function(_0x5fc982){if(_0x5fc982){return _0x5c2465['status'](_0xec84ce)[_0x2ec1('0x7')](_0x5fc982);}return null;};}function handleError(_0x1a8e4c,_0x2a0e45){_0x2a0e45=_0x2a0e45||0x1f4;return function(_0x18e68c){logger[_0x2ec1('0x8')](_0x18e68c[_0x2ec1('0x9')]);if(_0x18e68c[_0x2ec1('0xa')]){delete _0x18e68c['name'];}_0x1a8e4c[_0x2ec1('0xb')](_0x2a0e45)['send'](_0x18e68c);};}function execChildProcess(){return new BPromise(function(_0x11c5cf,_0x4efa13){exec(_0x2ec1('0xc'),function(_0x57ca09,_0x3c335d,_0x40d8cb){logger[_0x2ec1('0xd')](_0x3c335d);logger[_0x2ec1('0xd')](_0x40d8cb);if(_0x57ca09){logger['error'](_0x57ca09);return _0x4efa13(_0x57ca09);}return _0x11c5cf(_0x3c335d);});});}exports[_0x2ec1('0xe')]=function(_0x517614,_0x5cebb6){return pm2[_0x2ec1('0xf')]()[_0x2ec1('0x10')](function(_0x4c8b53){if(_0x4c8b53){var _0x3fd9c0=_[_0x2ec1('0x11')](_0x4c8b53,function(_0x50d725){return _0x50d725[_0x2ec1('0xa')]===_0x2ec1('0x12')||_0x50d725[_0x2ec1('0xa')]===_0x2ec1('0x13');});return{'rows':_0x3fd9c0,'count':_0x3fd9c0[_0x2ec1('0x14')]};}return null;})['then'](respondWithResult(_0x5cebb6,null))[_0x2ec1('0x15')](handleError(_0x5cebb6,null));};exports['show']=function(_0x59c175,_0x4bba09){return pm2['describe'](_0x59c175['params']['id'])['then'](respondWithResult(_0x4bba09,null))[_0x2ec1('0x10')](handleEntityNotFound(_0x4bba09,null))[_0x2ec1('0x15')](handleError(_0x4bba09,null));};exports[_0x2ec1('0x16')]=function(_0x47cd39,_0x4de962){if(_0x47cd39['body']['name']&&_0x47cd39['body'][_0x2ec1('0x17')]){var _0x25664c=path[_0x2ec1('0x18')](__dirname,_0x2ec1('0x19'),_0x47cd39[_0x2ec1('0x1a')]['script']);var _0xf03e2d=process[_0x2ec1('0x1b')]();process[_0x2ec1('0x1c')](path['dirname'](_0x25664c));return execChildProcess()[_0x2ec1('0x10')](function(_0x1c55ad){process[_0x2ec1('0x1c')](_0xf03e2d);return pm2['start']({'name':_0x47cd39[_0x2ec1('0x1a')][_0x2ec1('0xa')],'script':_0x25664c});})['then'](function(_0xb7e714){pm2['dump']();return _0xb7e714[0x0];})[_0x2ec1('0x10')](respondWithResult(_0x4de962,0xc9))[_0x2ec1('0x15')](handleError(_0x4de962,null));}else{return _0x4de962[_0x2ec1('0xb')](0x1f4)[_0x2ec1('0x1d')]({'message':_0x2ec1('0x1e')});}};exports[_0x2ec1('0x1f')]=function(_0x12da33,_0x46634f){if(_0x12da33['body']['id']){delete _0x12da33['body']['id'];}var _0x42cd16={'online':_0x2ec1('0x20'),'stopped':'stop'};if(_0x42cd16[_0x2ec1('0x21')](_0x12da33[_0x2ec1('0x1a')][_0x2ec1('0xb')])){return pm2[_0x42cd16[_0x12da33[_0x2ec1('0x1a')]['status']]](_0x12da33[_0x2ec1('0x22')]['id'])[_0x2ec1('0x10')](respondWithResult(_0x46634f,0xc8))[_0x2ec1('0x15')](handleError(_0x46634f,null));}else{return _0x46634f[_0x2ec1('0xb')](0x1f4)[_0x2ec1('0x1d')]({'message':'Unknown\x20status'});}};exports[_0x2ec1('0x23')]=function(_0x16a5df,_0x100a5c){if(_0x16a5df[_0x2ec1('0x1a')]['id']){delete _0x16a5df['body']['id'];}if(_0x16a5df[_0x2ec1('0x22')]['id']){return pm2[_0x2ec1('0x24')](_0x16a5df[_0x2ec1('0x22')]['id'])['then'](function(_0x5a21ab){pm2['dump']();return _0x5a21ab[0x0];})[_0x2ec1('0x10')](respondWithResult(_0x100a5c,null))['catch'](handleError(_0x100a5c,null));}else{return _0x100a5c[_0x2ec1('0xb')](0x1f4)[_0x2ec1('0x1d')]({'message':_0x2ec1('0x25')});}};
\ No newline at end of file
+var _0xaa03=['child_process','exec','bluebird','status','json','error','stack','name','send','npm\x20install','info','list','then','reject','express','length','catch','show','describe','create','body','script','join','../../files/plugins','chdir','dirname','start','dump','Missing\x20name\x20and/or\x20path','update','restart','hasOwnProperty','destroy','params','delete','lodash','../../config/pm2','../../config/logger','path'];(function(_0x1826e5,_0x54c849){var _0x151b91=function(_0x44c932){while(--_0x44c932){_0x1826e5['push'](_0x1826e5['shift']());}};_0x151b91(++_0x54c849);}(_0xaa03,0x134));var _0x3aa0=function(_0xceea66,_0x3a1b55){_0xceea66=_0xceea66-0x0;var _0x35867e=_0xaa03[_0xceea66];return _0x35867e;};'use strict';var _=require(_0x3aa0('0x0'));var pm2=require(_0x3aa0('0x1'));var logger=require(_0x3aa0('0x2'))('api');var path=require(_0x3aa0('0x3'));var exec=require(_0x3aa0('0x4'))[_0x3aa0('0x5')];var BPromise=require(_0x3aa0('0x6'));function handleEntityNotFound(_0x10297a,_0x2b2dc8){return function(_0x4c7af5){if(!_0x4c7af5){_0x10297a['sendStatus'](0x194);;}return _0x4c7af5;};}function respondWithResult(_0x107d38,_0x58f0d9){_0x58f0d9=_0x58f0d9||0xc8;return function(_0x534ae0){if(_0x534ae0){return _0x107d38[_0x3aa0('0x7')](_0x58f0d9)[_0x3aa0('0x8')](_0x534ae0);}return null;};}function handleError(_0xc4b1cc,_0x5d4205){_0x5d4205=_0x5d4205||0x1f4;return function(_0x200097){logger[_0x3aa0('0x9')](_0x200097[_0x3aa0('0xa')]);if(_0x200097[_0x3aa0('0xb')]){delete _0x200097['name'];}_0xc4b1cc['status'](_0x5d4205)[_0x3aa0('0xc')](_0x200097);};}function execChildProcess(){return new BPromise(function(_0x3f56fc,_0x4b988c){exec(_0x3aa0('0xd'),function(_0x551a24,_0x105293,_0x19dcfe){logger[_0x3aa0('0xe')](_0x105293);logger[_0x3aa0('0xe')](_0x19dcfe);if(_0x551a24){logger[_0x3aa0('0x9')](_0x551a24);return _0x4b988c(_0x551a24);}return _0x3f56fc(_0x105293);});});}exports['index']=function(_0x5b3bdc,_0x317173){return pm2[_0x3aa0('0xf')]()[_0x3aa0('0x10')](function(_0xa55b2d){if(_0xa55b2d){var _0x4c4bd8=_[_0x3aa0('0x11')](_0xa55b2d,function(_0x57e2e7){return _0x57e2e7['name']===_0x3aa0('0x12')||_0x57e2e7['name']==='motion2';});return{'rows':_0x4c4bd8,'count':_0x4c4bd8[_0x3aa0('0x13')]};}return null;})[_0x3aa0('0x10')](respondWithResult(_0x317173,null))[_0x3aa0('0x14')](handleError(_0x317173,null));};exports[_0x3aa0('0x15')]=function(_0x57bf17,_0x2aa7ae){return pm2[_0x3aa0('0x16')](_0x57bf17['params']['id'])[_0x3aa0('0x10')](respondWithResult(_0x2aa7ae,null))[_0x3aa0('0x10')](handleEntityNotFound(_0x2aa7ae,null))[_0x3aa0('0x14')](handleError(_0x2aa7ae,null));};exports[_0x3aa0('0x17')]=function(_0xf4d2f0,_0x4466c7){if(_0xf4d2f0[_0x3aa0('0x18')][_0x3aa0('0xb')]&&_0xf4d2f0['body'][_0x3aa0('0x19')]){var _0x580180=path[_0x3aa0('0x1a')](__dirname,_0x3aa0('0x1b'),_0xf4d2f0['body'][_0x3aa0('0x19')]);var _0x206838=process['cwd']();process[_0x3aa0('0x1c')](path[_0x3aa0('0x1d')](_0x580180));return execChildProcess()[_0x3aa0('0x10')](function(_0x21da21){process[_0x3aa0('0x1c')](_0x206838);return pm2[_0x3aa0('0x1e')]({'name':_0xf4d2f0[_0x3aa0('0x18')][_0x3aa0('0xb')],'script':_0x580180});})['then'](function(_0x161c43){pm2[_0x3aa0('0x1f')]();return _0x161c43[0x0];})[_0x3aa0('0x10')](respondWithResult(_0x4466c7,0xc9))[_0x3aa0('0x14')](handleError(_0x4466c7,null));}else{return _0x4466c7['status'](0x1f4)['send']({'message':_0x3aa0('0x20')});}};exports[_0x3aa0('0x21')]=function(_0x52fb19,_0x168f2e){if(_0x52fb19[_0x3aa0('0x18')]['id']){delete _0x52fb19[_0x3aa0('0x18')]['id'];}var _0x5b9f40={'online':_0x3aa0('0x22'),'stopped':'stop'};if(_0x5b9f40[_0x3aa0('0x23')](_0x52fb19[_0x3aa0('0x18')]['status'])){return pm2[_0x5b9f40[_0x52fb19[_0x3aa0('0x18')][_0x3aa0('0x7')]]](_0x52fb19['params']['id'])[_0x3aa0('0x10')](respondWithResult(_0x168f2e,0xc8))[_0x3aa0('0x14')](handleError(_0x168f2e,null));}else{return _0x168f2e['status'](0x1f4)[_0x3aa0('0xc')]({'message':'Unknown\x20status'});}};exports[_0x3aa0('0x24')]=function(_0x5a2213,_0x3b9a3e){if(_0x5a2213[_0x3aa0('0x18')]['id']){delete _0x5a2213[_0x3aa0('0x18')]['id'];}if(_0x5a2213[_0x3aa0('0x25')]['id']){return pm2[_0x3aa0('0x26')](_0x5a2213[_0x3aa0('0x25')]['id'])[_0x3aa0('0x10')](function(_0xd5d804){pm2['dump']();return _0xd5d804[0x0];})[_0x3aa0('0x10')](respondWithResult(_0x3b9a3e,null))[_0x3aa0('0x14')](handleError(_0x3b9a3e,null));}else{return _0x3b9a3e[_0x3aa0('0x7')](0x1f4)[_0x3aa0('0xc')]({'message':'Unknown\x20id'});}};
\ No newline at end of file