diff --git a/plugins/op_waf/waf/lua/common.lua b/plugins/op_waf/waf/lua/common.lua index f477fdbd6..09a2fa527 100644 --- a/plugins/op_waf/waf/lua/common.lua +++ b/plugins/op_waf/waf/lua/common.lua @@ -44,15 +44,17 @@ end function _M.getInstance(self) if rawget(self, "instance") == nil then rawset(self, "instance", self:new()) - - if 0 == ngx.worker.id() then - self:cron() - end end assert(self.instance ~= nil) return self.instance end +function _M:initCron(self) + if 0 == ngx.worker.id() then + self:cron() + end +end + function _M.initDB(self) local path = log_dir .. "/waf.db" db, err = sqlite3.open(path) diff --git a/plugins/op_waf/waf/lua/init_worker.lua b/plugins/op_waf/waf/lua/init_worker.lua index 5bf722c9d..172a8532a 100644 --- a/plugins/op_waf/waf/lua/init_worker.lua +++ b/plugins/op_waf/waf/lua/init_worker.lua @@ -15,6 +15,9 @@ local json = require "cjson" local __C = require "common" local C = __C:getInstance() +-- cron +C:initCron() + local function timer_stats_total_log(premature) C:timer_stats_total() end