Benchmark logging
This commit is contained in:
+22
-7
@@ -13,7 +13,20 @@ Package.prototype.rootNS = function( name, path )
|
||||
rootNS[ name ] = fs.realpathSync( path ) + "/";
|
||||
};
|
||||
|
||||
Package.prototype.load = function( _class, deCache )
|
||||
var _reload = function( e, filename )
|
||||
{
|
||||
if( this._lock )
|
||||
return;
|
||||
this._lock = true;
|
||||
|
||||
setTimeout( () =>
|
||||
{
|
||||
global.Dragonfly.Info( `Change detected: ${this.src}, reloading` );
|
||||
global.X_SERVER_CLUSTER.worker.destroy();
|
||||
} , 200 );
|
||||
};
|
||||
|
||||
Package.prototype.load = function( _class )
|
||||
{
|
||||
var fSep = _class.indexOf( "." );
|
||||
var nsdomain = _class.substr( 0, fSep );
|
||||
@@ -21,14 +34,16 @@ Package.prototype.load = function( _class, deCache )
|
||||
|
||||
var file = rootNS[ nsdomain ] + _class;
|
||||
|
||||
var lClass = require( file );
|
||||
// TODO: Implements filewatcher
|
||||
|
||||
if( deCache )
|
||||
if( global.debug && global.X_SERVER_CLUSTER )
|
||||
{
|
||||
delete require.cache[ require.resolve( file ) ];
|
||||
var src = require.resolve( file );
|
||||
if(!( src in require.cache ))
|
||||
{
|
||||
fs.watch( src, _reload.bind({ "src": src }) );
|
||||
}
|
||||
}
|
||||
return lClass;
|
||||
|
||||
return require( file );
|
||||
};
|
||||
|
||||
global.botanLoader = new Package();
|
||||
|
||||
Reference in New Issue
Block a user