Built motion from commit aab208717af8d15f4fa224cdb6a202877019af9b. Version 3.0.0...
[motion-next.git] / server / api / pm2 / pm2.controller.js
index 33d17cd..5f27617 100644 (file)
@@ -1 +1 @@
-const a521_0x585a=['reject','../../files/plugins','dump','send','body','destroy','stack','../../config/pm2','Unknown\x20id','show','script','index','update','api','Unknown\x20status','npm\x20install','lodash','stop','start','chdir','info','express','Missing\x20name\x20and/or\x20path','name','catch','describe','exec','list','undefined','delete','join','params','then','dirname','status'];(function(_0x5b7395,_0x585a9f){const _0x2bb349=function(_0x4febfc){while(--_0x4febfc){_0x5b7395['push'](_0x5b7395['shift']());}};_0x2bb349(++_0x585a9f);}(a521_0x585a,0x116));const a521_0x2bb3=function(_0x5b7395,_0x585a9f){_0x5b7395=_0x5b7395-0x0;let _0x2bb349=a521_0x585a[_0x5b7395];return _0x2bb349;};const _0x5e63d1=a521_0x2bb3;'use strict';const _=require(_0x5e63d1('0x12')),pm2=require(_0x5e63d1('0x9')),logger=require('../../config/logger')(_0x5e63d1('0xf')),path=require('path'),exec=require('child_process')[_0x5e63d1('0x1c')];function handleEntityNotFound(_0x4febfc){return function(_0x34e3ba){return!_0x34e3ba&&_0x4febfc['sendStatus'](0x194),_0x34e3ba;};}function respondWithResult(_0x1d2f32,_0x47cdbb){return _0x47cdbb=_0x47cdbb||0xc8,function(_0x53019c){const _0xbb323a=a521_0x2bb3;if(_0x53019c)return _0x1d2f32[_0xbb323a('0x1')](_0x47cdbb)['json'](_0x53019c);return null;};}function handleError(_0x1013f4,_0x1f9a19){return _0x1f9a19=_0x1f9a19||0x1f4,function(_0x5cc980){const _0x108b0f=a521_0x2bb3;logger['error'](_0x5cc980[_0x108b0f('0x8')]),_0x5cc980[_0x108b0f('0x19')]&&delete _0x5cc980['name'],_0x1013f4[_0x108b0f('0x1')](_0x1f9a19)[_0x108b0f('0x5')](_0x5cc980);};}function execChildProcess(){return new Promise(function(_0x14842c,_0x5e5259){const _0x39f998=a521_0x2bb3;exec(_0x39f998('0x11'),function(_0x3ceca7,_0x203bf9,_0x528546){const _0x27c611=_0x39f998;logger[_0x27c611('0x16')](_0x203bf9),logger[_0x27c611('0x16')](_0x528546);if(_0x3ceca7)return logger['error'](_0x3ceca7),_0x5e5259(_0x3ceca7);return _0x14842c(_0x203bf9);});});}exports[_0x5e63d1('0xd')]=function(_0x159861,_0x4d489a){const _0x92bb16=_0x5e63d1;return pm2[_0x92bb16('0x1d')]()[_0x92bb16('0x22')](function(_0x1e945c){const _0x2c71f0=_0x92bb16;if(_0x1e945c){const _0x4ecbcd=_[_0x2c71f0('0x2')](_0x1e945c,function(_0x2b644a){const _0x1ccc74=_0x2c71f0;return _0x2b644a['name']===_0x1ccc74('0x17')||_0x2b644a[_0x1ccc74('0x19')]==='motion2';});return{'rows':_0x4ecbcd,'count':_0x4ecbcd['length']};}return null;})[_0x92bb16('0x22')](respondWithResult(_0x4d489a,null))[_0x92bb16('0x1a')](handleError(_0x4d489a,null));},exports[_0x5e63d1('0xb')]=function(_0x2292f4,_0x40db65){const _0x2b2ab1=_0x5e63d1;return pm2[_0x2b2ab1('0x1b')](_0x2292f4[_0x2b2ab1('0x21')]['id'])[_0x2b2ab1('0x22')](respondWithResult(_0x40db65,null))[_0x2b2ab1('0x22')](handleEntityNotFound(_0x40db65,null))[_0x2b2ab1('0x1a')](handleError(_0x40db65,null));},exports['create']=function(_0x491412,_0x1f75ce){const _0x3e1cfd=_0x5e63d1;if(_0x491412['body'][_0x3e1cfd('0x19')]&&_0x491412[_0x3e1cfd('0x6')][_0x3e1cfd('0xc')]){const _0x45fb29=path[_0x3e1cfd('0x20')](__dirname,_0x3e1cfd('0x3'),_0x491412[_0x3e1cfd('0x6')][_0x3e1cfd('0xc')]),_0x2d48f1=process['cwd']();return process[_0x3e1cfd('0x15')](path[_0x3e1cfd('0x0')](_0x45fb29)),execChildProcess()[_0x3e1cfd('0x22')](function(){const _0x581a31=_0x3e1cfd;return process[_0x581a31('0x15')](_0x2d48f1),pm2[_0x581a31('0x14')]({'name':_0x491412[_0x581a31('0x6')][_0x581a31('0x19')],'script':_0x45fb29});})[_0x3e1cfd('0x22')](function(_0x2042de){const _0x3e0d99=_0x3e1cfd;return pm2[_0x3e0d99('0x4')](),_0x2042de[0x0];})[_0x3e1cfd('0x22')](respondWithResult(_0x1f75ce,0xc9))[_0x3e1cfd('0x1a')](handleError(_0x1f75ce,null));}else return _0x1f75ce[_0x3e1cfd('0x1')](0x1f4)[_0x3e1cfd('0x5')]({'message':_0x3e1cfd('0x18')});},exports[_0x5e63d1('0xe')]=function(_0x1f183b,_0x1a9ce3){const _0x5a3a6b=_0x5e63d1;_0x1f183b[_0x5a3a6b('0x6')]['id']&&delete _0x1f183b[_0x5a3a6b('0x6')]['id'];const _0x408e9c={'online':'restart','stopped':_0x5a3a6b('0x13')};return typeof _0x408e9c[_0x1f183b['body'][_0x5a3a6b('0x1')]]!==_0x5a3a6b('0x1e')?pm2[_0x408e9c[_0x1f183b[_0x5a3a6b('0x6')]['status']]](_0x1f183b['params']['id'])[_0x5a3a6b('0x22')](respondWithResult(_0x1a9ce3,0xc8))[_0x5a3a6b('0x1a')](handleError(_0x1a9ce3,null)):_0x1a9ce3[_0x5a3a6b('0x1')](0x1f4)[_0x5a3a6b('0x5')]({'message':_0x5a3a6b('0x10')});},exports[_0x5e63d1('0x7')]=function(_0x3a06aa,_0x39ea06){const _0xca47fd=_0x5e63d1;return _0x3a06aa['body']['id']&&delete _0x3a06aa[_0xca47fd('0x6')]['id'],_0x3a06aa['params']['id']?pm2[_0xca47fd('0x1f')](_0x3a06aa['params']['id'])['then'](function(_0x413020){const _0x2e09c7=_0xca47fd;return pm2[_0x2e09c7('0x4')](),_0x413020[0x0];})[_0xca47fd('0x22')](respondWithResult(_0x39ea06,null))['catch'](handleError(_0x39ea06,null)):_0x39ea06[_0xca47fd('0x1')](0x1f4)['send']({'message':_0xca47fd('0xa')});};
\ No newline at end of file
+const a521_0x1d3e=['stop','npm\x20install','stack','child_process','catch','Unknown\x20status','destroy','send','delete','error','info','Unknown\x20id','update','status','list','describe','api','length','express','then','join','restart','../../files/plugins','Missing\x20name\x20and/or\x20path','body','reject','undefined','chdir','script','create','dump','cwd','../../config/logger','json','params','name'];(function(_0x41d846,_0x1d3e3f){const _0x28bb9d=function(_0x52ea0d){while(--_0x52ea0d){_0x41d846['push'](_0x41d846['shift']());}};_0x28bb9d(++_0x1d3e3f);}(a521_0x1d3e,0x1de));const a521_0x28bb=function(_0x41d846,_0x1d3e3f){_0x41d846=_0x41d846-0x0;let _0x28bb9d=a521_0x1d3e[_0x41d846];return _0x28bb9d;};const _0x240dfe=a521_0x28bb;'use strict';const _=require('lodash'),pm2=require('../../config/pm2'),logger=require(_0x240dfe('0x16'))(_0x240dfe('0x6')),path=require('path'),exec=require(_0x240dfe('0x1d'))['exec'];function handleEntityNotFound(_0x52ea0d){return function(_0x4fbe85){return!_0x4fbe85&&_0x52ea0d['sendStatus'](0x194),_0x4fbe85;};}function respondWithResult(_0x1ba56f,_0x1168b6){return _0x1168b6=_0x1168b6||0xc8,function(_0x38853e){const _0xe80309=a521_0x28bb;if(_0x38853e)return _0x1ba56f[_0xe80309('0x3')](_0x1168b6)[_0xe80309('0x17')](_0x38853e);return null;};}function handleError(_0x5d4a1f,_0x344952){return _0x344952=_0x344952||0x1f4,function(_0x78227e){const _0x436be1=a521_0x28bb;logger[_0x436be1('0x23')](_0x78227e[_0x436be1('0x1c')]),_0x78227e[_0x436be1('0x19')]&&delete _0x78227e['name'],_0x5d4a1f['status'](_0x344952)[_0x436be1('0x21')](_0x78227e);};}function execChildProcess(){return new Promise(function(_0x450db3,_0x4346fd){const _0x34afa1=a521_0x28bb;exec(_0x34afa1('0x1b'),function(_0x4dc27c,_0x1b09ef,_0x2dc731){const _0x52682b=_0x34afa1;logger[_0x52682b('0x0')](_0x1b09ef),logger[_0x52682b('0x0')](_0x2dc731);if(_0x4dc27c)return logger[_0x52682b('0x23')](_0x4dc27c),_0x4346fd(_0x4dc27c);return _0x450db3(_0x1b09ef);});});}exports['index']=function(_0x21fcf7,_0x3bee41){const _0xd96aeb=_0x240dfe;return pm2[_0xd96aeb('0x4')]()['then'](function(_0x4b4d51){const _0x48f922=_0xd96aeb;if(_0x4b4d51){const _0x4341e6=_[_0x48f922('0xf')](_0x4b4d51,function(_0x418dba){const _0x3a905c=_0x48f922;return _0x418dba[_0x3a905c('0x19')]===_0x3a905c('0x8')||_0x418dba[_0x3a905c('0x19')]==='motion2';});return{'rows':_0x4341e6,'count':_0x4341e6[_0x48f922('0x7')]};}return null;})['then'](respondWithResult(_0x3bee41,null))[_0xd96aeb('0x1e')](handleError(_0x3bee41,null));},exports['show']=function(_0x483de0,_0x250878){const _0x3456a3=_0x240dfe;return pm2[_0x3456a3('0x5')](_0x483de0[_0x3456a3('0x18')]['id'])['then'](respondWithResult(_0x250878,null))[_0x3456a3('0x9')](handleEntityNotFound(_0x250878,null))['catch'](handleError(_0x250878,null));},exports[_0x240dfe('0x13')]=function(_0x4c07b6,_0xaa1842){const _0x2ffd82=_0x240dfe;if(_0x4c07b6[_0x2ffd82('0xe')]['name']&&_0x4c07b6[_0x2ffd82('0xe')][_0x2ffd82('0x12')]){const _0x4c50b8=path[_0x2ffd82('0xa')](__dirname,_0x2ffd82('0xc'),_0x4c07b6[_0x2ffd82('0xe')][_0x2ffd82('0x12')]),_0x36faca=process[_0x2ffd82('0x15')]();return process[_0x2ffd82('0x11')](path['dirname'](_0x4c50b8)),execChildProcess()[_0x2ffd82('0x9')](function(){const _0xe084ec=_0x2ffd82;return process['chdir'](_0x36faca),pm2['start']({'name':_0x4c07b6[_0xe084ec('0xe')]['name'],'script':_0x4c50b8});})['then'](function(_0x6e83e6){const _0x519c0f=_0x2ffd82;return pm2[_0x519c0f('0x14')](),_0x6e83e6[0x0];})[_0x2ffd82('0x9')](respondWithResult(_0xaa1842,0xc9))['catch'](handleError(_0xaa1842,null));}else return _0xaa1842[_0x2ffd82('0x3')](0x1f4)[_0x2ffd82('0x21')]({'message':_0x2ffd82('0xd')});},exports[_0x240dfe('0x2')]=function(_0x387127,_0xa2ca49){const _0x67c27e=_0x240dfe;_0x387127[_0x67c27e('0xe')]['id']&&delete _0x387127[_0x67c27e('0xe')]['id'];const _0x2f9759={'online':_0x67c27e('0xb'),'stopped':_0x67c27e('0x1a')};return typeof _0x2f9759[_0x387127['body']['status']]!==_0x67c27e('0x10')?pm2[_0x2f9759[_0x387127[_0x67c27e('0xe')][_0x67c27e('0x3')]]](_0x387127[_0x67c27e('0x18')]['id'])[_0x67c27e('0x9')](respondWithResult(_0xa2ca49,0xc8))[_0x67c27e('0x1e')](handleError(_0xa2ca49,null)):_0xa2ca49[_0x67c27e('0x3')](0x1f4)[_0x67c27e('0x21')]({'message':_0x67c27e('0x1f')});},exports[_0x240dfe('0x20')]=function(_0x591bff,_0x1084fb){const _0x428dd6=_0x240dfe;return _0x591bff['body']['id']&&delete _0x591bff['body']['id'],_0x591bff[_0x428dd6('0x18')]['id']?pm2[_0x428dd6('0x22')](_0x591bff[_0x428dd6('0x18')]['id'])['then'](function(_0x1e5ad4){return pm2['dump'](),_0x1e5ad4[0x0];})[_0x428dd6('0x9')](respondWithResult(_0x1084fb,null))[_0x428dd6('0x1e')](handleError(_0x1084fb,null)):_0x1084fb[_0x428dd6('0x3')](0x1f4)['send']({'message':_0x428dd6('0x1')});};
\ No newline at end of file