Skip to content

Commit

Permalink
reaper: SIGHUP calls Lua function "reload"
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Dec 6, 2023
1 parent 41a6ce1 commit 0557ac9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ cm4all-spawn (0.15) unstable; urgency=low

* reaper: refactor the Lua cgroup API
* reaper: add Lua attribute for inspecting a cgroup's parent
* reaper: SIGHUP calls Lua function "reload"
* systemd: remove dependency on "network.target"

--
Expand Down
8 changes: 8 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ This daemon watches cgroups below certain scopes; once they run empty,
statistics are collected and logged and the cgroup is deleted.


``SIGHUP``
^^^^^^^^^^

On ``systemctl reload cm4all-spawn-reaper`` (i.e. ``SIGHUP``), the
daemon calls the Lua function ``reload`` if one was defined. It is up
to the Lua script to define the exact meaning of this feature.


Resource Accounting
^^^^^^^^^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion libcommon
2 changes: 2 additions & 0 deletions src/reaper/Instance.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,6 @@ Instance::OnExit() noexcept
void
Instance::OnReload(int) noexcept
{
if (lua_accounting)
lua_accounting->Reload();
}
7 changes: 7 additions & 0 deletions src/reaper/LAccounting.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#pragma once

#include "lua/ReloadRunner.hxx"
#include "lua/State.hxx"
#include "lua/ValuePtr.hxx"
#include "util/IntrusiveList.hxx"
Expand All @@ -14,6 +15,8 @@ struct CgroupResourceUsage;
class LuaAccounting final {
Lua::State state;

Lua::ReloadRunner reload{state.get()};

const Lua::ValuePtr handler;

class Thread;
Expand All @@ -25,6 +28,10 @@ public:

~LuaAccounting() noexcept;

void Reload() noexcept {
reload.Start();
}

void InvokeCgroupReleased(UniqueFileDescriptor cgroup_fd,
const char *relative_path,
const CgroupResourceUsage &usage);
Expand Down

0 comments on commit 0557ac9

Please sign in to comment.