@brown-ds/distribution 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,5 +6,5 @@ Do NOT edit this file directly. Use it as a black box.
|
|
|
6
6
|
|
|
7
7
|
If you notice any issues with using this file, please contact the TAs.
|
|
8
8
|
*/
|
|
9
|
-
const http=require('http'),url=require('url'),log=require('../util/lo'+'g'),serialization=require('../util/se'+'rializatio'+'n');function isValidBody(
|
|
9
|
+
const http=require('http'),url=require('url'),log=require('../util/lo'+'g'),serialization=require('../util/se'+'rializatio'+'n');function isValidBody(_0x4c3a39){if(_0x4c3a39['length']===-0x2493+0x1399*0x1+0x10fa)return new Error('No\x20body');try{_0x4c3a39=JSON['parse'](_0x4c3a39);}catch(_0x59b2c1){return _0x59b2c1;}return undefined;}function endRequest(_0x57bcac,_0xf40322){_0x57bcac['end'](serialization['serialize']([_0xf40322]));}const start=function(_0xad6612){const _0x346156=http['createServ'+'er']((_0x2c7bc6,_0x764d1d)=>{if(_0x2c7bc6['method']!=='PUT'){_0x764d1d['end'](serialization['serialize'](new Error('Method\x20not'+'\x20allowed!')));return;}const _0x2cf799=url['parse'](_0x2c7bc6['url'])['pathname'],[,_0x2e70ee,_0x3c26fb,_0x29f792]=_0x2cf799['split']('/');log('[server]\x20g'+'ot\x20request'+'\x20'+_0x2e70ee+'\x20'+_0x3c26fb+':'+_0x29f792+'\x20from\x20'+_0x2c7bc6['connection']['remoteAddr'+'ess']);let _0x6e3a2b=[];_0x2c7bc6['on']('data',_0x5b5087=>{_0x6e3a2b['push'](_0x5b5087);}),_0x2c7bc6['on']('end',()=>{_0x6e3a2b=Buffer['concat'](_0x6e3a2b)['toString']();let _0x3c28d0;if(_0x3c28d0=isValidBody(_0x6e3a2b)){endRequest(_0x764d1d,_0x3c28d0);return;}_0x6e3a2b=JSON['parse'](_0x6e3a2b),_0x6e3a2b=serialization['deserializ'+'e'](_0x6e3a2b);const _0x58fb43=_0x6e3a2b;!Array['isArray'](_0x58fb43)&&endRequest(_0x764d1d,new Error('Invalid\x20ar'+'gument\x20typ'+'e,\x20expecte'+'d\x20array,\x20g'+'ot\x20'+typeof _0x58fb43));const _0x288319=_0x3c26fb;global['distributi'+'on']['local']['routes']['get']({'service':_0x3c26fb,'gid':_0x2e70ee},(_0x54c3b6,_0x250f7c)=>{const _0x3abf4b=(_0x77c04,_0x2cf3f4)=>{_0x764d1d['end'](serialization['serialize']([_0x77c04,_0x2cf3f4]));};if(_0x54c3b6){_0x3abf4b(_0x54c3b6);return;}if(!_0x250f7c[_0x29f792]){_0x3abf4b(new Error('Method\x20'+_0x29f792+('\x20not\x20found'+'\x20in\x20servic'+'e\x20')+_0x288319));return;}log('[server]\x20\x20'+'Calling\x20se'+'rvice:\x20'+_0x288319+':'+_0x29f792+('\x20with\x20args'+':\x20')+JSON['stringify'](_0x58fb43));_0x58fb43['length']===-0x12a9+-0x1*-0x960+0x1*0x94a&&_0x250f7c[_0x29f792]['length']===0x98a*-0x2+-0x27*-0x89+-0x1c8&&_0x58fb43['push'](undefined);try{_0x250f7c[_0x29f792](..._0x58fb43,_0x3abf4b);}catch(_0x5e53a3){_0x3abf4b(_0x5e53a3);}});});});_0x346156['listen'](global['nodeConfig']['port'],global['nodeConfig']['ip'],()=>{log('Server\x20run'+'ning\x20at\x20ht'+'tp://'+global['nodeConfig']['ip']+':'+global['nodeConfig']['port']+'/'),global['distributi'+'on']['node']['server']=_0x346156,_0xad6612(_0x346156);}),_0x346156['on']('error',_0x3b7e44=>{log('Server\x20err'+'or:\x20'+_0x3b7e44);throw _0x3b7e44;});};module['exports']={'start':start};
|
|
10
10
|
/* eslint-enable */
|
|
@@ -6,5 +6,5 @@ Do NOT edit this file directly. Use it as a black box.
|
|
|
6
6
|
|
|
7
7
|
If you notice any issues with using this file, please contact the TAs.
|
|
8
8
|
*/
|
|
9
|
-
const id=require('../util/id'),log=require('../util/lo'+'g'),status={};global['moreStatus']={'sid':id['getSID'](global['nodeConfig']),'nid':id['getNID'](global['nodeConfig']),'counts':0x0},status['get']=function(
|
|
9
|
+
const id=require('../util/id'),log=require('../util/lo'+'g'),status={};global['moreStatus']={'sid':id['getSID'](global['nodeConfig']),'nid':id['getNID'](global['nodeConfig']),'counts':0x0},status['get']=function(_0x2b5ce7,_0x5ee026){_0x5ee026=_0x5ee026||function(){};if(_0x2b5ce7 in global['nodeConfig']){_0x5ee026(null,global['nodeConfig'][_0x2b5ce7]);return;}if(_0x2b5ce7 in global['moreStatus']){_0x5ee026(null,global['moreStatus'][_0x2b5ce7]);return;}if(_0x2b5ce7==='heapTotal'){_0x5ee026(null,process['memoryUsag'+'e']()['heapTotal']);return;}if(_0x2b5ce7==='heapUsed'){_0x5ee026(null,process['memoryUsag'+'e']()['heapUsed']);return;}_0x5ee026(new Error('Status\x20key'+'\x20not\x20found'));};const path=require('path'),{spawn}=require('child_proc'+'ess'),wire=require('../util/wi'+'re'),createSpawnedCb=function(_0x5d134e,_0x4dae95){const _0x1a5ad8='\x0a\x20\x20\x20\x20let\x20o'+'nStart\x20=\x20'+_0x5d134e['toString']()+(';\x0a\x0a\x20\x20\x20\x20let'+'\x20callbackR'+'PC\x20=\x20')+wire['createRPC'](wire['toAsync'](_0x4dae95))['toString']()+(';\x0a\x0a\x20\x20\x20\x20try'+'\x20{\x0a\x20\x20\x20\x20\x20\x20\x20'+'\x20onStart()'+';\x0a\x20\x20\x20\x20\x20\x20\x20\x20'+'callbackRP'+'C(null,\x20gl'+'obal.nodeC'+'onfig,\x20()\x20'+'=>\x20{});\x0a\x20\x20'+'\x20\x20}\x0a\x20\x20\x20\x20ca'+'tch\x20(e)\x20{\x0a'+'\x20\x20\x20\x20\x20\x20\x20\x20ca'+'llbackRPC('+'e,\x20null,\x20('+')\x20=>\x20{});\x0a'+'\x20\x20\x20\x20}\x0a\x20\x20\x20\x20');return new Function(_0x1a5ad8);};status['spawn']=function(_0x3f1a05,_0x6d6fee){const _0x383824=_0x3f1a05;_0x383824['onStart']=_0x383824['onStart']||function(){};if(!_0x383824['port']||!_0x383824['ip']){_0x6d6fee(new Error('Port\x20and\x20I'+'P\x20are\x20requ'+'ired\x20in\x20th'+'e\x20configur'+'ation'));return;}log('[status.sp'+'awn]\x20Spawn'+'ing\x20node\x20w'+'ith\x20config'+'uration:\x20'+JSON['stringify'](_0x383824)),_0x383824['onStart']=createSpawnedCb(_0x383824['onStart'],_0x6d6fee);const _0x57dd81=path['join'](__dirname,'../../dist'+'ribution.j'+'s'),_0x51bab0=spawn('node',[_0x57dd81,'--config',global['distributi'+'on']['util']['serialize'](_0x383824)],{'detached':!![],'stdio':'inherit'});_0x51bab0;},status['stop']=function(_0x9812ba){_0x9812ba=_0x9812ba||function(){},_0x9812ba(null,global['nodeConfig']),log('[status.st'+'op]\x20Shutti'+'ng\x20down\x20no'+'de'),global['distributi'+'on']['node']['server']['close'](),process['exit'](0x1599+-0x2510+-0x6b*-0x25);},module['exports']=status;
|
|
10
10
|
/* eslint-enable */
|