Built motion from commit (unavailable).|2.4.0
[motion2.git] / server / api / pm2 / pm2.controller.js
index 1b3f3c4..f3a510e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb5dd=['body','join','script','chdir','dirname','start','dump','send','Missing\x20name\x20and/or\x20path','update','restart','stop','hasOwnProperty','Unknown\x20status','destroy','delete','Unknown\x20id','lodash','../../config/pm2','../../config/logger','api','path','exec','bluebird','sendStatus','status','json','stack','name','npm\x20install','info','error','index','then','express','length','catch','show','describe','params'];(function(_0x1d1779,_0x284147){var _0x2377e9=function(_0x299f6f){while(--_0x299f6f){_0x1d1779['push'](_0x1d1779['shift']());}};_0x2377e9(++_0x284147);}(_0xb5dd,0xd9));var _0xdb5d=function(_0x167cc1,_0x56ef5a){_0x167cc1=_0x167cc1-0x0;var _0x10bc4b=_0xb5dd[_0x167cc1];return _0x10bc4b;};'use strict';var _=require(_0xdb5d('0x0'));var pm2=require(_0xdb5d('0x1'));var logger=require(_0xdb5d('0x2'))(_0xdb5d('0x3'));var path=require(_0xdb5d('0x4'));var exec=require('child_process')[_0xdb5d('0x5')];var BPromise=require(_0xdb5d('0x6'));function handleEntityNotFound(_0x292af1,_0x5ba1dd){return function(_0x477651){if(!_0x477651){_0x292af1[_0xdb5d('0x7')](0x194);;}return _0x477651;};}function respondWithResult(_0x43afa8,_0x13996b){_0x13996b=_0x13996b||0xc8;return function(_0x2d980b){if(_0x2d980b){return _0x43afa8[_0xdb5d('0x8')](_0x13996b)[_0xdb5d('0x9')](_0x2d980b);}return null;};}function handleError(_0x9c836e,_0x2f7984){_0x2f7984=_0x2f7984||0x1f4;return function(_0x82ef9){logger['error'](_0x82ef9[_0xdb5d('0xa')]);if(_0x82ef9[_0xdb5d('0xb')]){delete _0x82ef9[_0xdb5d('0xb')];}_0x9c836e['status'](_0x2f7984)['send'](_0x82ef9);};}function execChildProcess(){return new BPromise(function(_0xeb1c09,_0x38ab9a){exec(_0xdb5d('0xc'),function(_0x56eb05,_0x4f6b19,_0xa69efe){logger[_0xdb5d('0xd')](_0x4f6b19);logger[_0xdb5d('0xd')](_0xa69efe);if(_0x56eb05){logger[_0xdb5d('0xe')](_0x56eb05);return _0x38ab9a(_0x56eb05);}return _0xeb1c09(_0x4f6b19);});});}exports[_0xdb5d('0xf')]=function(_0x114c34,_0x32311){return pm2['list']()[_0xdb5d('0x10')](function(_0x418c41){if(_0x418c41){var _0x4e5100=_['reject'](_0x418c41,function(_0x7c81ef){return _0x7c81ef[_0xdb5d('0xb')]===_0xdb5d('0x11')||_0x7c81ef['name']==='motion2';});return{'rows':_0x4e5100,'count':_0x4e5100[_0xdb5d('0x12')]};}return null;})['then'](respondWithResult(_0x32311,null))[_0xdb5d('0x13')](handleError(_0x32311,null));};exports[_0xdb5d('0x14')]=function(_0x204b8f,_0xea500e){return pm2[_0xdb5d('0x15')](_0x204b8f[_0xdb5d('0x16')]['id'])[_0xdb5d('0x10')](respondWithResult(_0xea500e,null))['then'](handleEntityNotFound(_0xea500e,null))[_0xdb5d('0x13')](handleError(_0xea500e,null));};exports['create']=function(_0x263d2d,_0x405d3d){if(_0x263d2d[_0xdb5d('0x17')][_0xdb5d('0xb')]&&_0x263d2d[_0xdb5d('0x17')]['script']){var _0x3f53ea=path[_0xdb5d('0x18')](__dirname,'../../files/plugins',_0x263d2d['body'][_0xdb5d('0x19')]);var _0x3329fd=process['cwd']();process[_0xdb5d('0x1a')](path[_0xdb5d('0x1b')](_0x3f53ea));return execChildProcess()['then'](function(_0x3894fa){process['chdir'](_0x3329fd);return pm2[_0xdb5d('0x1c')]({'name':_0x263d2d['body'][_0xdb5d('0xb')],'script':_0x3f53ea});})['then'](function(_0x485f61){pm2[_0xdb5d('0x1d')]();return _0x485f61[0x0];})['then'](respondWithResult(_0x405d3d,0xc9))['catch'](handleError(_0x405d3d,null));}else{return _0x405d3d[_0xdb5d('0x8')](0x1f4)[_0xdb5d('0x1e')]({'message':_0xdb5d('0x1f')});}};exports[_0xdb5d('0x20')]=function(_0x334e35,_0x4e3d2d){if(_0x334e35[_0xdb5d('0x17')]['id']){delete _0x334e35[_0xdb5d('0x17')]['id'];}var _0x1f231a={'online':_0xdb5d('0x21'),'stopped':_0xdb5d('0x22')};if(_0x1f231a[_0xdb5d('0x23')](_0x334e35[_0xdb5d('0x17')]['status'])){return pm2[_0x1f231a[_0x334e35[_0xdb5d('0x17')][_0xdb5d('0x8')]]](_0x334e35[_0xdb5d('0x16')]['id'])['then'](respondWithResult(_0x4e3d2d,0xc8))['catch'](handleError(_0x4e3d2d,null));}else{return _0x4e3d2d[_0xdb5d('0x8')](0x1f4)['send']({'message':_0xdb5d('0x24')});}};exports[_0xdb5d('0x25')]=function(_0x3affd3,_0x962c02){if(_0x3affd3[_0xdb5d('0x17')]['id']){delete _0x3affd3['body']['id'];}if(_0x3affd3['params']['id']){return pm2[_0xdb5d('0x26')](_0x3affd3[_0xdb5d('0x16')]['id'])[_0xdb5d('0x10')](function(_0x22e9a4){pm2[_0xdb5d('0x1d')]();return _0x22e9a4[0x0];})['then'](respondWithResult(_0x962c02,null))[_0xdb5d('0x13')](handleError(_0x962c02,null));}else{return _0x962c02[_0xdb5d('0x8')](0x1f4)[_0xdb5d('0x1e')]({'message':_0xdb5d('0x27')});}};
\ No newline at end of file
+var _0x9261=['cwd','chdir','dirname','dump','update','restart','stop','hasOwnProperty','Unknown\x20status','destroy','lodash','../../config/pm2','api','path','child_process','bluebird','sendStatus','status','json','error','stack','name','send','npm\x20install','info','index','list','then','reject','express','motion2','catch','describe','params','create','body','join','../../files/plugins','script'];(function(_0x11a962,_0x3cc338){var _0x55d423=function(_0xf4b236){while(--_0xf4b236){_0x11a962['push'](_0x11a962['shift']());}};_0x55d423(++_0x3cc338);}(_0x9261,0x1de));var _0x1926=function(_0x4067ac,_0x363603){_0x4067ac=_0x4067ac-0x0;var _0x53d74d=_0x9261[_0x4067ac];return _0x53d74d;};'use strict';var _=require(_0x1926('0x0'));var pm2=require(_0x1926('0x1'));var logger=require('../../config/logger')(_0x1926('0x2'));var path=require(_0x1926('0x3'));var exec=require(_0x1926('0x4'))['exec'];var BPromise=require(_0x1926('0x5'));function handleEntityNotFound(_0x2fb805,_0x269cb1){return function(_0x31eef2){if(!_0x31eef2){_0x2fb805[_0x1926('0x6')](0x194);;}return _0x31eef2;};}function respondWithResult(_0x549cec,_0x17f1c6){_0x17f1c6=_0x17f1c6||0xc8;return function(_0x4cf00b){if(_0x4cf00b){return _0x549cec[_0x1926('0x7')](_0x17f1c6)[_0x1926('0x8')](_0x4cf00b);}return null;};}function handleError(_0x4b2a5f,_0x37affe){_0x37affe=_0x37affe||0x1f4;return function(_0x2fb92c){logger[_0x1926('0x9')](_0x2fb92c[_0x1926('0xa')]);if(_0x2fb92c[_0x1926('0xb')]){delete _0x2fb92c[_0x1926('0xb')];}_0x4b2a5f[_0x1926('0x7')](_0x37affe)[_0x1926('0xc')](_0x2fb92c);};}function execChildProcess(){return new BPromise(function(_0x284dd6,_0x1ec703){exec(_0x1926('0xd'),function(_0xdf0c50,_0x2d20b5,_0x382bcc){logger[_0x1926('0xe')](_0x2d20b5);logger[_0x1926('0xe')](_0x382bcc);if(_0xdf0c50){logger[_0x1926('0x9')](_0xdf0c50);return _0x1ec703(_0xdf0c50);}return _0x284dd6(_0x2d20b5);});});}exports[_0x1926('0xf')]=function(_0x2ac6d3,_0x30e4a0){return pm2[_0x1926('0x10')]()[_0x1926('0x11')](function(_0x2ed996){if(_0x2ed996){var _0x4ff9ff=_[_0x1926('0x12')](_0x2ed996,function(_0x472e41){return _0x472e41['name']===_0x1926('0x13')||_0x472e41[_0x1926('0xb')]===_0x1926('0x14');});return{'rows':_0x4ff9ff,'count':_0x4ff9ff['length']};}return null;})[_0x1926('0x11')](respondWithResult(_0x30e4a0,null))[_0x1926('0x15')](handleError(_0x30e4a0,null));};exports['show']=function(_0x21e214,_0x4552e0){return pm2[_0x1926('0x16')](_0x21e214[_0x1926('0x17')]['id'])[_0x1926('0x11')](respondWithResult(_0x4552e0,null))[_0x1926('0x11')](handleEntityNotFound(_0x4552e0,null))[_0x1926('0x15')](handleError(_0x4552e0,null));};exports[_0x1926('0x18')]=function(_0x1e4b49,_0x3e452b){if(_0x1e4b49[_0x1926('0x19')][_0x1926('0xb')]&&_0x1e4b49[_0x1926('0x19')]['script']){var _0x4866f5=path[_0x1926('0x1a')](__dirname,_0x1926('0x1b'),_0x1e4b49[_0x1926('0x19')][_0x1926('0x1c')]);var _0x2361e2=process[_0x1926('0x1d')]();process[_0x1926('0x1e')](path[_0x1926('0x1f')](_0x4866f5));return execChildProcess()[_0x1926('0x11')](function(_0x3e0ab0){process[_0x1926('0x1e')](_0x2361e2);return pm2['start']({'name':_0x1e4b49['body']['name'],'script':_0x4866f5});})['then'](function(_0x447d76){pm2[_0x1926('0x20')]();return _0x447d76[0x0];})[_0x1926('0x11')](respondWithResult(_0x3e452b,0xc9))[_0x1926('0x15')](handleError(_0x3e452b,null));}else{return _0x3e452b['status'](0x1f4)['send']({'message':'Missing\x20name\x20and/or\x20path'});}};exports[_0x1926('0x21')]=function(_0x142f45,_0x55385a){if(_0x142f45[_0x1926('0x19')]['id']){delete _0x142f45[_0x1926('0x19')]['id'];}var _0x3cb4ee={'online':_0x1926('0x22'),'stopped':_0x1926('0x23')};if(_0x3cb4ee[_0x1926('0x24')](_0x142f45[_0x1926('0x19')][_0x1926('0x7')])){return pm2[_0x3cb4ee[_0x142f45[_0x1926('0x19')]['status']]](_0x142f45[_0x1926('0x17')]['id'])[_0x1926('0x11')](respondWithResult(_0x55385a,0xc8))[_0x1926('0x15')](handleError(_0x55385a,null));}else{return _0x55385a[_0x1926('0x7')](0x1f4)['send']({'message':_0x1926('0x25')});}};exports[_0x1926('0x26')]=function(_0x406631,_0x11ecc9){if(_0x406631[_0x1926('0x19')]['id']){delete _0x406631['body']['id'];}if(_0x406631[_0x1926('0x17')]['id']){return pm2['delete'](_0x406631[_0x1926('0x17')]['id'])[_0x1926('0x11')](function(_0x2dfb79){pm2[_0x1926('0x20')]();return _0x2dfb79[0x0];})['then'](respondWithResult(_0x11ecc9,null))[_0x1926('0x15')](handleError(_0x11ecc9,null));}else{return _0x11ecc9[_0x1926('0x7')](0x1f4)[_0x1926('0xc')]({'message':'Unknown\x20id'});}};
\ No newline at end of file