diff --git a/plugins/op_waf/waf/lua/waf_common.lua b/plugins/op_waf/waf/lua/waf_common.lua index 029bc40d5..10f254987 100644 --- a/plugins/op_waf/waf/lua/waf_common.lua +++ b/plugins/op_waf/waf/lua/waf_common.lua @@ -41,6 +41,14 @@ function _M.new(self) end +-- function _M.getInstance(self) +-- if rawget(self, "instance") == nil then +-- rawset(self, "instance", self.new()) +-- end +-- assert(self.instance ~= nil) +-- return self.instance +-- end + function _M.getInstance(self) if self.instance == nil then self.instance = self:new() diff --git a/plugins/webstats/lua/webstats_common.lua b/plugins/webstats/lua/webstats_common.lua index 8858a55eb..eb0194ce5 100644 --- a/plugins/webstats/lua/webstats_common.lua +++ b/plugins/webstats/lua/webstats_common.lua @@ -42,10 +42,19 @@ function _M.new(self) end +-- function _M.getInstance(self) +-- if rawget(self, "instance") == nil then +-- rawset(self, "instance", self.new()) +-- self.cron() +-- end +-- assert(self.instance ~= nil) +-- return self.instance +-- end + + function _M.getInstance(self) - if rawget(self, "instance") == nil then - rawset(self, "instance", self.new()) - self.cron() + if self.instance == nil then + self.instance = self:new() end assert(self.instance ~= nil) return self.instance diff --git a/plugins/webstats/lua/webstats_worker.lua b/plugins/webstats/lua/webstats_worker.lua index 53a4b0d8c..2eda941e6 100644 --- a/plugins/webstats/lua/webstats_worker.lua +++ b/plugins/webstats/lua/webstats_worker.lua @@ -17,4 +17,5 @@ end if ngx.worker.id() == 0 then ngx.timer.every(60, webstats_cron_pre) + WS_C:cron() end \ No newline at end of file