Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

statusbot add parameter for db cleanup #183

Closed
wants to merge 9 commits into from
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ bundle-server:
mv fgcom-mumble-server-$(SERVER_VER)/statuspage/Readme.statuspage.md fgcom-mumble-server-$(SERVER_VER)
cp server/Readme.server-de_DE.md fgcom-mumble-server-$(SERVER_VER)/
cp server/fgcom-botmanager.sh server/*.bot.lua fgcom-mumble-server-$(SERVER_VER)
sed '/^\s\+gitver/s/""/"$(GITVER) $(GITDATE)"/' server/sharedFunctions.inc.lua > fgcom-mumble-server-$(SERVER_VER)/sharedFunctions.inc.lua
sed '/^\s\+gitver/s/""/"$(GITVER) $(GITDATE)"/' server/fgcom-sharedFunctions.inc.lua > fgcom-mumble-server-$(SERVER_VER)/fgcom-sharedFunctions.inc.lua
zip -r fgcom-mumble-server-$(SERVER_VER).zip fgcom-mumble-server-$(SERVER_VER)
rm -rf fgcom-mumble-server-$(SERVER_VER)

Expand Down
2 changes: 1 addition & 1 deletion server/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION: 1.1.4
VERSION: 1.1.5
2 changes: 1 addition & 1 deletion server/fgcom-radio-playback.bot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The bot is depending on lua-mumble from bkacjios (https://github.com/bkacjios/l
Installation of this plugin is described in the projects readme: https://github.com/bkacjios/lua-mumble/blob/master/README.md

]]
dofile("sharedFunctions.inc.lua") -- include shared functions
dofile("fgcom-sharedFunctions.inc.lua") -- include shared functions
fgcom.botversion = "1.8.1"

-- init random generator using /dev/random, if poosible (=linux)
Expand Down
2 changes: 1 addition & 1 deletion server/fgcom-radio-recorder.bot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Installation of this plugin is described in the projects readme: https://github.

]]

dofile("sharedFunctions.inc.lua") -- include shared functions
dofile("fgcom-sharedFunctions.inc.lua") -- include shared functions
fgcom.botversion = "1.8.1"
local botname = "FGCOM-Recorder"
fgcom.callsign = "FGCOM-REC"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ end
-- FGCom functions
fgcom = {
botversion = "unknown",
libversion = "1.7.0",
libversion = "1.8.0",
gitver = "", -- will be set from makefile when bundling
channel = "fgcom-mumble",
callsign = "FGCOM-someUnknownBot",
Expand Down Expand Up @@ -308,7 +308,9 @@ fgcom = {
end

-- check if we already know this clients identity with given iid; if not, add template
if not fgcom_clients[sid][iid] then
if fgcom_clients[sid][iid] then
if fgcom.hooks.parsePluginData_updateKnownClient ~= nil then fgcom.hooks.parsePluginData_updateKnownClient(sid, iid) end
else
fgcom_clients[sid][iid] = {
callsign="",
lat="",
Expand All @@ -317,6 +319,7 @@ fgcom = {
radios={},
lastUpdate=0
}
if fgcom.hooks.parsePluginData_newClient ~= nil then fgcom.hooks.parsePluginData_newClient(sid, iid) end
end

-- record that we had an data update
Expand Down Expand Up @@ -369,6 +372,8 @@ fgcom = {
fgcom.dbg("parsing field failed! "..#field.." tokens seen")
end
end

if fgcom.hooks.parsePluginData_afterParseIID ~= nil then fgcom.hooks.parsePluginData_afterParseIID(sid, iid) end

elseif packtype == "PING" then
-- update the contained identites lastUpdate timestamps
Expand All @@ -378,11 +383,16 @@ fgcom = {
if fgcom_clients[sid][iid] then
fgcom_clients[sid][iid].lastUpdate = os.time()
end

if fgcom.hooks.parsePluginData_afterParseIID ~= nil then fgcom.hooks.parsePluginData_afterParseIID(sid, iid) end
end

elseif packtype == "ICANHAZDATAPLZ" then
-- ignore for now
end

fgcom.dbg("Packet fully processed.")
if fgcom.hooks.parsePluginData_processedPacket ~= nil then fgcom.hooks.parsePluginData_processedPacket(sender, packtype, dataID_t) end
end

fgcom.dbg("Parsing done. New remote state:")
Expand All @@ -398,6 +408,9 @@ fgcom = {
fgcom.dbg("sid="..uid.."; idty="..iid.." radio #"..radio_id.." pwr='"..radio.power.."'")
fgcom.dbg("sid="..uid.."; idty="..iid.." radio #"..radio_id.." opr='"..radio.operable.."'")
end
elseif k == "lastUpdate" then
local last_updated_since = os.time() - v
fgcom.dbg("sid="..uid.."; idty="..iid.."\t"..k..":\t"..tostring(v).." ("..last_updated_since.."s ago)")
else
fgcom.dbg("sid="..uid.."; idty="..iid.."\t"..k..":\t"..tostring(v))
end
Expand All @@ -416,7 +429,10 @@ fgcom = {
local stale_since = os.time() - idty.lastUpdate
if stale_since > fgcom.data.cleanupTimeout then
fgcom.dbg("cleanup remote data: sid="..uid.."; idty="..iid.." stale_since="..stale_since)
fgcom_clients[uid][iid] = nil;
local process = true
if fgcom.hooks.cleanupPluginData_entry ~= nil then process=fgcom.hooks.cleanupPluginData_entry(uid, iid) end

if process then fgcom_clients[uid][iid] = nil end
end
end
end
Expand Down Expand Up @@ -476,6 +492,27 @@ fgcom = {
end
return fgcom.auth.isAuthenticated(user)
end,
},

-- Various hooks, bots can implement to have event based adjustment options.
-- If they are not defined, they will not be called.
hooks = {
-- parsePluginData_afterParseIID(sid, iid)
-- called when parsePluginData() received data for a given iid

-- fgcom.hooks.parsePluginData_newClient(sid, iid)
-- called when parsePluginData() detected that the client was not seen before.
-- is called before any datas is parsed/added.

-- fgcom.hooks.parsePluginData_updateKnownClient(sid, iid)
-- called when parsePluginData() detected that the client was known.
-- is called before any datas is parsed/updated.

-- fgcom.hooks.parsePluginData_processedPacket(mumble_user, packtype, dataID_t)
-- called after processing the packet, passing raw data

-- fgcom.hooks.cleanupPluginData_entry(sid, iid)
-- called when cleaning up an entry. return false to prevent the entry to be cleaned out.
}
}

Expand Down
9 changes: 6 additions & 3 deletions server/statuspage/config.dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
;

[json-database]
; path to database file
file="/tmp/fgcom-web.db"
; path to database file (provided by the statusbot)
file="/tmp/fgcom-web.db"


[ui]
Expand All @@ -19,7 +19,10 @@ db_stale=15
; after this many seconds, stale entries will be marked as such
mark_stale_entries=30

; after this many seconds, stale entries will not be displayed anymore
; after this many seconds, stale entries will not be displayed anymore.
; NOTE: this value should be equal or less the --purge parameter of the statusbot,
; you cannot exceed the bots db purge setting (purged stale entries are not visible
; to the statuspage, so cannot be displayed).
hide_stale_entries=60

; Show link to usage statistics.
Expand Down
Loading
Loading