From 4207a5b90eb2e48120f4eb8e9224c94d74139a3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Mon, 4 Apr 2022 22:28:39 +0900 Subject: [PATCH] Using worker id as lock --- net/WebFrame.js | 3 +-- package.js | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/net/WebFrame.js b/net/WebFrame.js index e78e8cb..d8348bd 100644 --- a/net/WebFrame.js +++ b/net/WebFrame.js @@ -2,6 +2,7 @@ const zlib = require( "zlib" ); const os = require( "os" ) +const fs = require( "fs" ); const cl = global.botanLoader; const Dragonfly = global.Dragonfly; @@ -204,8 +205,6 @@ class WebFrame resp.headers[ "Content-Disposition" ] = "attachment; filename=\"" + name + "\""; - var fs = require( "fs" ); - Dragonfly.Debug( "Stream out: " + path ); var rs = fs.createReadStream( path ); diff --git a/package.js b/package.js index 9322c7a..5aa9fff 100644 --- a/package.js +++ b/package.js @@ -15,9 +15,9 @@ Package.prototype.rootNS = function( name, path ) var _reload = function( e, filename ) { - if( this._lock ) + if( this._lock == global.X_SERVER_CLUSTER.worker.id ) return; - this._lock = true; + this._lock = global.X_SERVER_CLUSTER.worker.id; setTimeout( () => { @@ -34,7 +34,7 @@ Package.prototype.load = function( _class ) var file = rootNS[ nsdomain ] + _class; - if( global.debug && global.X_SERVER_CLUSTER ) + if( global.debug && global.X_SERVER_CLUSTER && global.X_SERVER_CLUSTER.worker ) { var src = require.resolve( file ); if(!( src in require.cache ))