网站统计

This commit is contained in:
midoks 2023-02-12 00:22:39 +08:00
parent 45c2b3cdca
commit 29144595a6
5 changed files with 22 additions and 12 deletions

View File

@ -260,15 +260,15 @@ def initDreplace():
loadLuaFile(fl)
root_worker_dir = mw.getServerDir() + '/web_conf/nginx/lua/init_worker_by_lua_file'
webstats_worker_dst_file = root_worker_dir + '/webstats_worker.lua'
dst_file = root_worker_dir + '/webstats_worker.lua'
if not os.path.exists(webstats_worker_src_file):
if not os.path.exists(dst_file):
loadLuaFile('webstats_worker.lua')
webstats_worker_src_file = lua_dir = getServerDir() + "/lua/webstats_worker.lua"
content = mw.readFile(webstats_worker_src_file)
mw.writeFile(webstats_worker_dst_file, content)
src_file = getServerDir() + "/lua/webstats_worker.lua"
content = mw.readFile(src_file)
mw.writeFile(dst_file, content)
mw.opLuaInitWorkerFile()
os.remove(webstats_worker_src_file)
os.remove(src_file)
loadConfigFile()
loadLuaSiteFile()
@ -302,9 +302,9 @@ def stop():
os.remove(path)
root_worker_dir = mw.getServerDir() + '/web_conf/nginx/lua/init_worker_by_lua_file'
webstats_worker_dst_file = root_worker_dir + '/webstats_worker.lua'
if os.path.exists(webstats_worker_dst_file):
os.remove(webstats_worker_dst_file)
dst_file = root_worker_dir + '/webstats_worker.lua'
if os.path.exists(dst_file):
os.remove(dst_file)
mw.opLuaInitWorkerFile()
import tool_task

View File

@ -4,7 +4,7 @@
"name": "webstats",
"title": "网站统计",
"shell": "install.sh",
"versions":["0.2.3"],
"versions":["0.2.4"],
"tip": "soft",
"install_pre_inspection":true,
"checks": "server/webstats",

View File

@ -36,6 +36,8 @@ function _M.new(self)
params = nil,
site_config = nil,
config = nil,
cron_num = 0,
cron_num_limit = 4,
}
-- self.dbs = {}
@ -254,6 +256,13 @@ end
-- 后台任务
function _M.cron(self)
self.cron_num = self.cron_num + 1
if self.cron_num > self.cron_num_limit then
return
end
-- self:D("PID:"..tostring(ngx.worker.id())..",cron_num:"..tostring(self.cron_num))
local timer_every_get_data = function (premature)
local llen, _ = ngx.shared.mw_total:llen(total_key)

View File

@ -8,7 +8,7 @@ log_by_lua_block {
package.path = cpath .. "?.lua;" .. package.path
end
local ver = '0.2.3'
local ver = '0.2.4'
local debug_mode = true
local __C = require "webstats_common"

View File

@ -10,11 +10,12 @@ local __WS_C = require "webstats_common"
local WS_C = __WS_C:getInstance()
WS_C:cronPre()
WS_C:cron()
local webstats_cron_pre = function(premature)
WS_C:cronPre()
end
if ngx.worker.id() == 0 then
ngx.timer.every(60, webstats_cron_pre)
WS_C:cron()
end