Built motion from commit (unavailable).|2.3.95
[motion2.git] / server / api / pm2 / pm2.controller.js
index 34b7d34..1db8b67 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb778=['describe','catch','create','body','../../files/plugins','dump','update','restart','stop','params','Unknown\x20status','destroy','delete','Unknown\x20id','lodash','../../config/logger','child_process','exec','bluebird','status','json','error','stack','name','send','npm\x20install','info','index','list','then','reject','express','length','show'];(function(_0x3054be,_0x1bdc8b){var _0x3df150=function(_0x56cfbf){while(--_0x56cfbf){_0x3054be['push'](_0x3054be['shift']());}};_0x3df150(++_0x1bdc8b);}(_0xb778,0x1c8));var _0x8b77=function(_0xe27810,_0x8b3e76){_0xe27810=_0xe27810-0x0;var _0x53dcec=_0xb778[_0xe27810];return _0x53dcec;};'use strict';var _=require(_0x8b77('0x0'));var pm2=require('../../config/pm2');var logger=require(_0x8b77('0x1'))('api');var path=require('path');var exec=require(_0x8b77('0x2'))[_0x8b77('0x3')];var BPromise=require(_0x8b77('0x4'));function handleEntityNotFound(_0x1d9fc7,_0x2a79ef){return function(_0x3f309a){if(!_0x3f309a){_0x1d9fc7['sendStatus'](0x194);;}return _0x3f309a;};}function respondWithResult(_0x361cbc,_0x43012d){_0x43012d=_0x43012d||0xc8;return function(_0x527afa){if(_0x527afa){return _0x361cbc[_0x8b77('0x5')](_0x43012d)[_0x8b77('0x6')](_0x527afa);}return null;};}function handleError(_0x5b9096,_0x1a7405){_0x1a7405=_0x1a7405||0x1f4;return function(_0x4909ef){logger[_0x8b77('0x7')](_0x4909ef[_0x8b77('0x8')]);if(_0x4909ef[_0x8b77('0x9')]){delete _0x4909ef['name'];}_0x5b9096['status'](_0x1a7405)[_0x8b77('0xa')](_0x4909ef);};}function execChildProcess(){return new BPromise(function(_0x52a5e8,_0x1bcdea){exec(_0x8b77('0xb'),function(_0x131fd5,_0x22c145,_0x3bfb26){logger[_0x8b77('0xc')](_0x22c145);logger[_0x8b77('0xc')](_0x3bfb26);if(_0x131fd5){logger[_0x8b77('0x7')](_0x131fd5);return _0x1bcdea(_0x131fd5);}return _0x52a5e8(_0x22c145);});});}exports[_0x8b77('0xd')]=function(_0x11efa6,_0x34f429){return pm2[_0x8b77('0xe')]()[_0x8b77('0xf')](function(_0x63828d){if(_0x63828d){var _0x54b21c=_[_0x8b77('0x10')](_0x63828d,function(_0x1b613d){return _0x1b613d[_0x8b77('0x9')]===_0x8b77('0x11')||_0x1b613d[_0x8b77('0x9')]==='motion2';});return{'rows':_0x54b21c,'count':_0x54b21c[_0x8b77('0x12')]};}return null;})[_0x8b77('0xf')](respondWithResult(_0x34f429,null))['catch'](handleError(_0x34f429,null));};exports[_0x8b77('0x13')]=function(_0x3392de,_0xd2e0e6){return pm2[_0x8b77('0x14')](_0x3392de['params']['id'])['then'](respondWithResult(_0xd2e0e6,null))[_0x8b77('0xf')](handleEntityNotFound(_0xd2e0e6,null))[_0x8b77('0x15')](handleError(_0xd2e0e6,null));};exports[_0x8b77('0x16')]=function(_0x195fee,_0x28a316){if(_0x195fee[_0x8b77('0x17')]['name']&&_0x195fee['body']['script']){var _0x479c05=path['join'](__dirname,_0x8b77('0x18'),_0x195fee[_0x8b77('0x17')]['script']);var _0x459f5d=process['cwd']();process['chdir'](path['dirname'](_0x479c05));return execChildProcess()[_0x8b77('0xf')](function(_0xa881de){process['chdir'](_0x459f5d);return pm2['start']({'name':_0x195fee[_0x8b77('0x17')][_0x8b77('0x9')],'script':_0x479c05});})['then'](function(_0x16d0e1){pm2[_0x8b77('0x19')]();return _0x16d0e1[0x0];})[_0x8b77('0xf')](respondWithResult(_0x28a316,0xc9))[_0x8b77('0x15')](handleError(_0x28a316,null));}else{return _0x28a316[_0x8b77('0x5')](0x1f4)['send']({'message':'Missing\x20name\x20and/or\x20path'});}};exports[_0x8b77('0x1a')]=function(_0x57a559,_0x5ba4ce){if(_0x57a559[_0x8b77('0x17')]['id']){delete _0x57a559[_0x8b77('0x17')]['id'];}var _0x4e3e00={'online':_0x8b77('0x1b'),'stopped':_0x8b77('0x1c')};if(_0x4e3e00['hasOwnProperty'](_0x57a559[_0x8b77('0x17')][_0x8b77('0x5')])){return pm2[_0x4e3e00[_0x57a559['body'][_0x8b77('0x5')]]](_0x57a559[_0x8b77('0x1d')]['id'])['then'](respondWithResult(_0x5ba4ce,0xc8))['catch'](handleError(_0x5ba4ce,null));}else{return _0x5ba4ce[_0x8b77('0x5')](0x1f4)['send']({'message':_0x8b77('0x1e')});}};exports[_0x8b77('0x1f')]=function(_0x556cdf,_0x8ba8a8){if(_0x556cdf['body']['id']){delete _0x556cdf[_0x8b77('0x17')]['id'];}if(_0x556cdf[_0x8b77('0x1d')]['id']){return pm2[_0x8b77('0x20')](_0x556cdf[_0x8b77('0x1d')]['id'])[_0x8b77('0xf')](function(_0x55d635){pm2[_0x8b77('0x19')]();return _0x55d635[0x0];})[_0x8b77('0xf')](respondWithResult(_0x8ba8a8,null))['catch'](handleError(_0x8ba8a8,null));}else{return _0x8ba8a8[_0x8b77('0x5')](0x1f4)['send']({'message':_0x8b77('0x21')});}};
\ No newline at end of file
+var _0xf15b=['cwd','chdir','dirname','start','dump','Missing\x20name\x20and/or\x20path','update','restart','stop','hasOwnProperty','lodash','../../config/logger','api','path','child_process','exec','bluebird','sendStatus','error','status','send','npm\x20install','info','index','list','then','reject','name','express','motion2','show','describe','params','catch','create','body','script','join','../../files/plugins'];(function(_0x584e3e,_0x1b0ca1){var _0x5622fd=function(_0x4201d6){while(--_0x4201d6){_0x584e3e['push'](_0x584e3e['shift']());}};_0x5622fd(++_0x1b0ca1);}(_0xf15b,0x7f));var _0xbf15=function(_0x55933f,_0x33712b){_0x55933f=_0x55933f-0x0;var _0x588e8d=_0xf15b[_0x55933f];return _0x588e8d;};'use strict';var _=require(_0xbf15('0x0'));var pm2=require('../../config/pm2');var logger=require(_0xbf15('0x1'))(_0xbf15('0x2'));var path=require(_0xbf15('0x3'));var exec=require(_0xbf15('0x4'))[_0xbf15('0x5')];var BPromise=require(_0xbf15('0x6'));function handleEntityNotFound(_0x2f3542,_0x105221){return function(_0xeb8a3d){if(!_0xeb8a3d){_0x2f3542[_0xbf15('0x7')](0x194);;}return _0xeb8a3d;};}function respondWithResult(_0x501077,_0x4e2643){_0x4e2643=_0x4e2643||0xc8;return function(_0x5b46fa){if(_0x5b46fa){return _0x501077['status'](_0x4e2643)['json'](_0x5b46fa);}return null;};}function handleError(_0x220409,_0x2a54db){_0x2a54db=_0x2a54db||0x1f4;return function(_0x4e7d7f){logger[_0xbf15('0x8')](_0x4e7d7f['stack']);if(_0x4e7d7f['name']){delete _0x4e7d7f['name'];}_0x220409[_0xbf15('0x9')](_0x2a54db)[_0xbf15('0xa')](_0x4e7d7f);};}function execChildProcess(){return new BPromise(function(_0x3fc1db,_0x50c08c){exec(_0xbf15('0xb'),function(_0x54b1ef,_0x5769b9,_0xf1543e){logger[_0xbf15('0xc')](_0x5769b9);logger[_0xbf15('0xc')](_0xf1543e);if(_0x54b1ef){logger['error'](_0x54b1ef);return _0x50c08c(_0x54b1ef);}return _0x3fc1db(_0x5769b9);});});}exports[_0xbf15('0xd')]=function(_0x2bdcbf,_0x1db5f2){return pm2[_0xbf15('0xe')]()[_0xbf15('0xf')](function(_0x41bc6a){if(_0x41bc6a){var _0x412156=_[_0xbf15('0x10')](_0x41bc6a,function(_0x2f90e5){return _0x2f90e5[_0xbf15('0x11')]===_0xbf15('0x12')||_0x2f90e5[_0xbf15('0x11')]===_0xbf15('0x13');});return{'rows':_0x412156,'count':_0x412156['length']};}return null;})[_0xbf15('0xf')](respondWithResult(_0x1db5f2,null))['catch'](handleError(_0x1db5f2,null));};exports[_0xbf15('0x14')]=function(_0x18f862,_0x4fe053){return pm2[_0xbf15('0x15')](_0x18f862[_0xbf15('0x16')]['id'])[_0xbf15('0xf')](respondWithResult(_0x4fe053,null))['then'](handleEntityNotFound(_0x4fe053,null))[_0xbf15('0x17')](handleError(_0x4fe053,null));};exports[_0xbf15('0x18')]=function(_0xf7918e,_0x33b169){if(_0xf7918e[_0xbf15('0x19')][_0xbf15('0x11')]&&_0xf7918e['body'][_0xbf15('0x1a')]){var _0x2319c1=path[_0xbf15('0x1b')](__dirname,_0xbf15('0x1c'),_0xf7918e['body'][_0xbf15('0x1a')]);var _0x57431d=process[_0xbf15('0x1d')]();process[_0xbf15('0x1e')](path[_0xbf15('0x1f')](_0x2319c1));return execChildProcess()['then'](function(_0x471244){process[_0xbf15('0x1e')](_0x57431d);return pm2[_0xbf15('0x20')]({'name':_0xf7918e[_0xbf15('0x19')][_0xbf15('0x11')],'script':_0x2319c1});})['then'](function(_0x8fa2cd){pm2[_0xbf15('0x21')]();return _0x8fa2cd[0x0];})[_0xbf15('0xf')](respondWithResult(_0x33b169,0xc9))[_0xbf15('0x17')](handleError(_0x33b169,null));}else{return _0x33b169[_0xbf15('0x9')](0x1f4)[_0xbf15('0xa')]({'message':_0xbf15('0x22')});}};exports[_0xbf15('0x23')]=function(_0x39318b,_0x4d237e){if(_0x39318b[_0xbf15('0x19')]['id']){delete _0x39318b[_0xbf15('0x19')]['id'];}var _0x2119ad={'online':_0xbf15('0x24'),'stopped':_0xbf15('0x25')};if(_0x2119ad[_0xbf15('0x26')](_0x39318b[_0xbf15('0x19')][_0xbf15('0x9')])){return pm2[_0x2119ad[_0x39318b[_0xbf15('0x19')][_0xbf15('0x9')]]](_0x39318b[_0xbf15('0x16')]['id'])['then'](respondWithResult(_0x4d237e,0xc8))[_0xbf15('0x17')](handleError(_0x4d237e,null));}else{return _0x4d237e[_0xbf15('0x9')](0x1f4)[_0xbf15('0xa')]({'message':'Unknown\x20status'});}};exports['destroy']=function(_0xf390e,_0x1a798f){if(_0xf390e[_0xbf15('0x19')]['id']){delete _0xf390e['body']['id'];}if(_0xf390e[_0xbf15('0x16')]['id']){return pm2['delete'](_0xf390e[_0xbf15('0x16')]['id'])[_0xbf15('0xf')](function(_0x1c48a1){pm2[_0xbf15('0x21')]();return _0x1c48a1[0x0];})['then'](respondWithResult(_0x1a798f,null))[_0xbf15('0x17')](handleError(_0x1a798f,null));}else{return _0x1a798f[_0xbf15('0x9')](0x1f4)[_0xbf15('0xa')]({'message':'Unknown\x20id'});}};
\ No newline at end of file