Built motion from commit (unavailable).|2.5.0
[motion2.git] / server / api / pm2 / pm2.controller.js
index 7083207..f9d3173 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x88b4=['npm\x20install','info','index','list','then','reject','express','motion2','length','catch','show','describe','params','create','body','script','join','../../files/plugins','cwd','chdir','dirname','start','dump','send','Missing\x20name\x20and/or\x20path','update','restart','stop','hasOwnProperty','destroy','delete','Unknown\x20id','lodash','../../config/pm2','../../config/logger','api','path','child_process','exec','bluebird','sendStatus','json','error','stack','name','status'];(function(_0x586363,_0x37701a){var _0xbec4c9=function(_0x2dfeb9){while(--_0x2dfeb9){_0x586363['push'](_0x586363['shift']());}};_0xbec4c9(++_0x37701a);}(_0x88b4,0x7c));var _0x488b=function(_0x212a37,_0xf35b2e){_0x212a37=_0x212a37-0x0;var _0x5d0bf9=_0x88b4[_0x212a37];return _0x5d0bf9;};'use strict';var _=require(_0x488b('0x0'));var pm2=require(_0x488b('0x1'));var logger=require(_0x488b('0x2'))(_0x488b('0x3'));var path=require(_0x488b('0x4'));var exec=require(_0x488b('0x5'))[_0x488b('0x6')];var BPromise=require(_0x488b('0x7'));function handleEntityNotFound(_0x2e53b0,_0x5c9f55){return function(_0xa1a702){if(!_0xa1a702){_0x2e53b0[_0x488b('0x8')](0x194);;}return _0xa1a702;};}function respondWithResult(_0x2d5025,_0x2ba66b){_0x2ba66b=_0x2ba66b||0xc8;return function(_0x965277){if(_0x965277){return _0x2d5025['status'](_0x2ba66b)[_0x488b('0x9')](_0x965277);}return null;};}function handleError(_0xc046f3,_0x2fdc5a){_0x2fdc5a=_0x2fdc5a||0x1f4;return function(_0x2de949){logger[_0x488b('0xa')](_0x2de949[_0x488b('0xb')]);if(_0x2de949[_0x488b('0xc')]){delete _0x2de949[_0x488b('0xc')];}_0xc046f3[_0x488b('0xd')](_0x2fdc5a)['send'](_0x2de949);};}function execChildProcess(){return new BPromise(function(_0xfbffe1,_0x5b3008){exec(_0x488b('0xe'),function(_0x4959d9,_0x86d000,_0x444911){logger['info'](_0x86d000);logger[_0x488b('0xf')](_0x444911);if(_0x4959d9){logger[_0x488b('0xa')](_0x4959d9);return _0x5b3008(_0x4959d9);}return _0xfbffe1(_0x86d000);});});}exports[_0x488b('0x10')]=function(_0x55611b,_0x2df377){return pm2[_0x488b('0x11')]()[_0x488b('0x12')](function(_0x541c75){if(_0x541c75){var _0x1767e4=_[_0x488b('0x13')](_0x541c75,function(_0x2913fc){return _0x2913fc[_0x488b('0xc')]===_0x488b('0x14')||_0x2913fc[_0x488b('0xc')]===_0x488b('0x15');});return{'rows':_0x1767e4,'count':_0x1767e4[_0x488b('0x16')]};}return null;})['then'](respondWithResult(_0x2df377,null))[_0x488b('0x17')](handleError(_0x2df377,null));};exports[_0x488b('0x18')]=function(_0x2a3794,_0x48ba0b){return pm2[_0x488b('0x19')](_0x2a3794[_0x488b('0x1a')]['id'])[_0x488b('0x12')](respondWithResult(_0x48ba0b,null))['then'](handleEntityNotFound(_0x48ba0b,null))[_0x488b('0x17')](handleError(_0x48ba0b,null));};exports[_0x488b('0x1b')]=function(_0x22363b,_0x3ab565){if(_0x22363b[_0x488b('0x1c')][_0x488b('0xc')]&&_0x22363b['body'][_0x488b('0x1d')]){var _0x3e6415=path[_0x488b('0x1e')](__dirname,_0x488b('0x1f'),_0x22363b[_0x488b('0x1c')][_0x488b('0x1d')]);var _0x247414=process[_0x488b('0x20')]();process[_0x488b('0x21')](path[_0x488b('0x22')](_0x3e6415));return execChildProcess()[_0x488b('0x12')](function(_0x29a483){process['chdir'](_0x247414);return pm2[_0x488b('0x23')]({'name':_0x22363b['body'][_0x488b('0xc')],'script':_0x3e6415});})['then'](function(_0x216af0){pm2[_0x488b('0x24')]();return _0x216af0[0x0];})['then'](respondWithResult(_0x3ab565,0xc9))[_0x488b('0x17')](handleError(_0x3ab565,null));}else{return _0x3ab565['status'](0x1f4)[_0x488b('0x25')]({'message':_0x488b('0x26')});}};exports[_0x488b('0x27')]=function(_0x28fc66,_0x3a4a0a){if(_0x28fc66[_0x488b('0x1c')]['id']){delete _0x28fc66[_0x488b('0x1c')]['id'];}var _0x463e5a={'online':_0x488b('0x28'),'stopped':_0x488b('0x29')};if(_0x463e5a[_0x488b('0x2a')](_0x28fc66[_0x488b('0x1c')]['status'])){return pm2[_0x463e5a[_0x28fc66[_0x488b('0x1c')]['status']]](_0x28fc66[_0x488b('0x1a')]['id'])['then'](respondWithResult(_0x3a4a0a,0xc8))[_0x488b('0x17')](handleError(_0x3a4a0a,null));}else{return _0x3a4a0a[_0x488b('0xd')](0x1f4)[_0x488b('0x25')]({'message':'Unknown\x20status'});}};exports[_0x488b('0x2b')]=function(_0x5c071b,_0xe1599){if(_0x5c071b[_0x488b('0x1c')]['id']){delete _0x5c071b[_0x488b('0x1c')]['id'];}if(_0x5c071b[_0x488b('0x1a')]['id']){return pm2[_0x488b('0x2c')](_0x5c071b[_0x488b('0x1a')]['id'])[_0x488b('0x12')](function(_0x5d5575){pm2[_0x488b('0x24')]();return _0x5d5575[0x0];})[_0x488b('0x12')](respondWithResult(_0xe1599,null))[_0x488b('0x17')](handleError(_0xe1599,null));}else{return _0xe1599[_0x488b('0xd')](0x1f4)[_0x488b('0x25')]({'message':_0x488b('0x2d')});}};
\ No newline at end of file
+var _0x8c5b=['dump','Missing\x20name\x20and/or\x20path','restart','Unknown\x20status','destroy','delete','../../config/pm2','../../config/logger','api','child_process','exec','status','error','stack','name','send','npm\x20install','info','index','list','reject','length','then','catch','show','params','create','script','../../files/plugins','body','cwd','chdir','dirname','start'];(function(_0x555ff2,_0x4ece49){var _0x2eba05=function(_0x5473b5){while(--_0x5473b5){_0x555ff2['push'](_0x555ff2['shift']());}};_0x2eba05(++_0x4ece49);}(_0x8c5b,0x8e));var _0xb8c5=function(_0x463183,_0x56bd4e){_0x463183=_0x463183-0x0;var _0xd5fe56=_0x8c5b[_0x463183];return _0xd5fe56;};'use strict';var _=require('lodash');var pm2=require(_0xb8c5('0x0'));var logger=require(_0xb8c5('0x1'))(_0xb8c5('0x2'));var path=require('path');var exec=require(_0xb8c5('0x3'))[_0xb8c5('0x4')];var BPromise=require('bluebird');function handleEntityNotFound(_0x1e93dd,_0x48dc7d){return function(_0x2d4c9b){if(!_0x2d4c9b){_0x1e93dd['sendStatus'](0x194);;}return _0x2d4c9b;};}function respondWithResult(_0xdb851d,_0x1adb2e){_0x1adb2e=_0x1adb2e||0xc8;return function(_0x25cece){if(_0x25cece){return _0xdb851d[_0xb8c5('0x5')](_0x1adb2e)['json'](_0x25cece);}return null;};}function handleError(_0x920263,_0x5c0a55){_0x5c0a55=_0x5c0a55||0x1f4;return function(_0x30cbb5){logger[_0xb8c5('0x6')](_0x30cbb5[_0xb8c5('0x7')]);if(_0x30cbb5[_0xb8c5('0x8')]){delete _0x30cbb5[_0xb8c5('0x8')];}_0x920263[_0xb8c5('0x5')](_0x5c0a55)[_0xb8c5('0x9')](_0x30cbb5);};}function execChildProcess(){return new BPromise(function(_0x24539a,_0x4580a5){exec(_0xb8c5('0xa'),function(_0x360e00,_0x573162,_0x313464){logger[_0xb8c5('0xb')](_0x573162);logger[_0xb8c5('0xb')](_0x313464);if(_0x360e00){logger[_0xb8c5('0x6')](_0x360e00);return _0x4580a5(_0x360e00);}return _0x24539a(_0x573162);});});}exports[_0xb8c5('0xc')]=function(_0x537174,_0x1dcb7e){return pm2[_0xb8c5('0xd')]()['then'](function(_0x370af5){if(_0x370af5){var _0x5b9d05=_[_0xb8c5('0xe')](_0x370af5,function(_0x4dc00e){return _0x4dc00e[_0xb8c5('0x8')]==='express'||_0x4dc00e[_0xb8c5('0x8')]==='motion2';});return{'rows':_0x5b9d05,'count':_0x5b9d05[_0xb8c5('0xf')]};}return null;})[_0xb8c5('0x10')](respondWithResult(_0x1dcb7e,null))[_0xb8c5('0x11')](handleError(_0x1dcb7e,null));};exports[_0xb8c5('0x12')]=function(_0x377e86,_0x5ec425){return pm2['describe'](_0x377e86[_0xb8c5('0x13')]['id'])[_0xb8c5('0x10')](respondWithResult(_0x5ec425,null))[_0xb8c5('0x10')](handleEntityNotFound(_0x5ec425,null))[_0xb8c5('0x11')](handleError(_0x5ec425,null));};exports[_0xb8c5('0x14')]=function(_0x144062,_0x2e3424){if(_0x144062['body'][_0xb8c5('0x8')]&&_0x144062['body'][_0xb8c5('0x15')]){var _0x1333ce=path['join'](__dirname,_0xb8c5('0x16'),_0x144062[_0xb8c5('0x17')]['script']);var _0x57c71a=process[_0xb8c5('0x18')]();process[_0xb8c5('0x19')](path[_0xb8c5('0x1a')](_0x1333ce));return execChildProcess()[_0xb8c5('0x10')](function(_0x3e0456){process[_0xb8c5('0x19')](_0x57c71a);return pm2[_0xb8c5('0x1b')]({'name':_0x144062['body']['name'],'script':_0x1333ce});})[_0xb8c5('0x10')](function(_0x442f4d){pm2[_0xb8c5('0x1c')]();return _0x442f4d[0x0];})[_0xb8c5('0x10')](respondWithResult(_0x2e3424,0xc9))[_0xb8c5('0x11')](handleError(_0x2e3424,null));}else{return _0x2e3424[_0xb8c5('0x5')](0x1f4)['send']({'message':_0xb8c5('0x1d')});}};exports['update']=function(_0x3519f3,_0x6b4eb3){if(_0x3519f3['body']['id']){delete _0x3519f3[_0xb8c5('0x17')]['id'];}var _0x59e0fd={'online':_0xb8c5('0x1e'),'stopped':'stop'};if(_0x59e0fd['hasOwnProperty'](_0x3519f3['body'][_0xb8c5('0x5')])){return pm2[_0x59e0fd[_0x3519f3[_0xb8c5('0x17')][_0xb8c5('0x5')]]](_0x3519f3[_0xb8c5('0x13')]['id'])[_0xb8c5('0x10')](respondWithResult(_0x6b4eb3,0xc8))[_0xb8c5('0x11')](handleError(_0x6b4eb3,null));}else{return _0x6b4eb3[_0xb8c5('0x5')](0x1f4)['send']({'message':_0xb8c5('0x1f')});}};exports[_0xb8c5('0x20')]=function(_0x40b6f9,_0x210924){if(_0x40b6f9[_0xb8c5('0x17')]['id']){delete _0x40b6f9[_0xb8c5('0x17')]['id'];}if(_0x40b6f9[_0xb8c5('0x13')]['id']){return pm2[_0xb8c5('0x21')](_0x40b6f9[_0xb8c5('0x13')]['id'])[_0xb8c5('0x10')](function(_0x32004f){pm2['dump']();return _0x32004f[0x0];})[_0xb8c5('0x10')](respondWithResult(_0x210924,null))[_0xb8c5('0x11')](handleError(_0x210924,null));}else{return _0x210924['status'](0x1f4)[_0xb8c5('0x9')]({'message':'Unknown\x20id'});}};
\ No newline at end of file