Skip to content
Snippets Groups Projects
Commit 3bec5f5c authored by Vaclav Sraier's avatar Vaclav Sraier Committed by Aleš Mrázek
Browse files

manager: generated config: opening control socket at correct path with stable id

parent 183462ec
Branches
Tags
No related merge requests found
import os
import pathlib
import sys
from typing import Dict, Optional, Union
......@@ -117,4 +118,7 @@ class KresConfig(SchemaNode):
return obj.dns64
def render_lua(self) -> str:
return _MAIN_TEMPLATE.render(cfg=self) # pyright: reportUnknownMemberType=false
# FIXME the `cwd` argument is used only for configuring control socket path
# it should be removed and relative path used instead as soon as issue
# https://gitlab.nic.cz/knot/knot-resolver/-/issues/720 is fixed
return _MAIN_TEMPLATE.render(cfg=self, cwd=os.getcwd()) # pyright: reportUnknownMemberType=false
......@@ -52,3 +52,19 @@
{% if cfg.lua.script %}
{{ cfg.lua.script }}
{% endif %}
-- static config used for manager's needs
local ffi = require('ffi')
local id = os.getenv('SYSTEMD_INSTANCE')
if not id then
log_err(ffi.C.LOG_GRP_SYSTEM, 'environment variable $SYSTEMD_INSTANCE not set, which should not have been possible due to running under manager')
else
-- Bind to control socket in CWD (= rundir in config)
-- FIXME replace with relative path after fixing https://gitlab.nic.cz/knot/knot-resolver/-/issues/720
local path = '{{ cwd }}/control/'..id
log_warn(ffi.C.LOG_GRP_SYSTEM, 'path = ' .. path)
local ok, err = pcall(net.listen, path, nil, { kind = 'control' })
if not ok then
log_warn(ffi.C.LOG_GRP_NETWORK, 'bind to '..path..' failed '..err)
end
end
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment