mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-09 03:10:27 +00:00
Add redbean OnServerHeartbeat hook
This commit is contained in:
parent
634fdf0a3f
commit
7ec2196f0b
2 changed files with 11 additions and 1 deletions
|
@ -554,6 +554,12 @@ HOOKS
|
|||
each time redbean reaps a child connection process using wait4().
|
||||
This won't be called in uniprocess mode.
|
||||
|
||||
OnServerHeartbeat()
|
||||
If this function is defined it'll be called from the main process
|
||||
on each server heartbeat. The heartbeat interval is configurable
|
||||
with ProgramHeartbeatInterval. If this hook is defined, then
|
||||
`/.heartbeat.lua` is not called.
|
||||
|
||||
OnServerListen(socketdescriptor:int,serverip:int,serverport:int) → bool
|
||||
If this function is defined it'll be called from the main process
|
||||
before redbean starts listening on a port. This hook can be used
|
||||
|
|
|
@ -5745,7 +5745,11 @@ static void HandleHeartbeat(void) {
|
|||
Reindex();
|
||||
getrusage(RUSAGE_SELF, &shared->server);
|
||||
#ifndef STATIC
|
||||
LuaRunAsset("/.heartbeat.lua", false);
|
||||
if (IsHookDefined("OnServerHeartbeat")) {
|
||||
CallSimpleHook("OnServerHeartbeat");
|
||||
} else {
|
||||
LuaRunAsset("/.heartbeat.lua", false);
|
||||
}
|
||||
CollectGarbage();
|
||||
#endif
|
||||
for (i = 1; i < servers.n; ++i) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue