Benchmark logging
This commit is contained in:
		@@ -93,7 +93,7 @@ class Dragonfly
 | 
				
			|||||||
		var tag = cluster.isMaster ? "M" : "S";
 | 
							var tag = cluster.isMaster ? "M" : "S";
 | 
				
			||||||
		this.ptag = "[ " + tag + ":" + process.pid + " ] ";
 | 
							this.ptag = "[ " + tag + ":" + process.pid + " ] ";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		this.Info( "Dragonfly ready.", Dragonfly.Visibility.VISIBLE );
 | 
							// this.Info( "Dragonfly ready.", Dragonfly.Visibility.VISIBLE );
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Debug( mesg, visibility )
 | 
						Debug( mesg, visibility )
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -57,6 +57,7 @@ function AppDomain( handler, port, cluster )
 | 
				
			|||||||
	var http = require( "http" );
 | 
						var http = require( "http" );
 | 
				
			||||||
	var server = http.createServer(
 | 
						var server = http.createServer(
 | 
				
			||||||
		function(req, res) {
 | 
							function(req, res) {
 | 
				
			||||||
 | 
								res._hrtime = process.hrtime.bigint();
 | 
				
			||||||
			serverHandle( server, req, res, handler );
 | 
								serverHandle( server, req, res, handler );
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	);
 | 
						);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -169,7 +169,7 @@ class WebFrame
 | 
				
			|||||||
		this.HTTP.response.headers["Content-Length"] = data.length;
 | 
							this.HTTP.response.headers["Content-Length"] = data.length;
 | 
				
			||||||
		this.HTTP.response.write( data );
 | 
							this.HTTP.response.write( data );
 | 
				
			||||||
		this.HTTP.response.end();
 | 
							this.HTTP.response.end();
 | 
				
			||||||
		Dragonfly.Debug( "Result Planted" );
 | 
							Dragonfly.Debug( `Result Planted: ${process.hrtime.bigint() - this.HTTP.response.raw._hrtime}ns` );
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	__storeCache( data, cache, ttl )
 | 
						__storeCache( data, cache, ttl )
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										29
									
								
								package.js
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								package.js
									
									
									
									
									
								
							@@ -13,7 +13,20 @@ Package.prototype.rootNS = function( name, path )
 | 
				
			|||||||
	rootNS[ name ] = fs.realpathSync( 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 fSep = _class.indexOf( "." );
 | 
				
			||||||
	var nsdomain = _class.substr( 0, fSep );
 | 
						var nsdomain = _class.substr( 0, fSep );
 | 
				
			||||||
@@ -21,14 +34,16 @@ Package.prototype.load = function( _class, deCache )
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	var file = rootNS[ nsdomain ] + _class;
 | 
						var file = rootNS[ nsdomain ] + _class;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var lClass = require( file );
 | 
						if( global.debug && global.X_SERVER_CLUSTER )
 | 
				
			||||||
	// TODO: Implements filewatcher
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if( deCache )
 | 
					 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		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();
 | 
					global.botanLoader = new Package();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -50,7 +50,7 @@ class PageCache
 | 
				
			|||||||
			, headers: {
 | 
								, headers: {
 | 
				
			||||||
				"Content-Length": res.headers[ "Content-Length" ]
 | 
									"Content-Length": res.headers[ "Content-Length" ]
 | 
				
			||||||
				, "Content-Type": res.headers[ "Content-Type" ]
 | 
									, "Content-Type": res.headers[ "Content-Type" ]
 | 
				
			||||||
				, "X-Cache-Expires": new Date( expires )
 | 
									, "X-Cache-Expirls": new Date( expires ).toISOString()
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			, statusCode: res.statusCode
 | 
								, statusCode: res.statusCode
 | 
				
			||||||
			, ttl: expires
 | 
								, ttl: expires
 | 
				
			||||||
@@ -87,18 +87,19 @@ class PageCache
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		if( url in store )
 | 
							if( url in store )
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			Dragonfly.Info(
 | 
					 | 
				
			||||||
				"[C] "
 | 
					 | 
				
			||||||
				+ ( req.headers[ "x-forwarded-for" ] || req.connection.remoteAddress ) + " "
 | 
					 | 
				
			||||||
				+ req.method + ": " + encodeURI( url )
 | 
					 | 
				
			||||||
				+ " - " + req.headers["user-agent"]
 | 
					 | 
				
			||||||
				, Dragonfly.Visibility.VISIBLE
 | 
					 | 
				
			||||||
			);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			var c = store[ url ];
 | 
								var c = store[ url ];
 | 
				
			||||||
			res.writeHead( c.statusCode, c.headers );
 | 
								res.writeHead( c.statusCode, c.headers );
 | 
				
			||||||
			res.end( c.data );
 | 
								res.end( c.data );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								Dragonfly.Info(
 | 
				
			||||||
 | 
									"[C] "
 | 
				
			||||||
 | 
									+ ( req.headers[ "x-forwarded-for" ] || req.connection.remoteAddress ) + " "
 | 
				
			||||||
 | 
									+ req.method + ": " + url
 | 
				
			||||||
 | 
									+ " - " + req.headers["user-agent"]
 | 
				
			||||||
 | 
									+ ` in ${process.hrtime.bigint() - res._hrtime}ns`
 | 
				
			||||||
 | 
									, Dragonfly.Visibility.VISIBLE
 | 
				
			||||||
 | 
								);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			return true;
 | 
								return true;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user