forked from kenzuya/unshackle
fix(serve): reject a config reload whose validation exits instead of stopping the server
This commit is contained in:
@@ -188,12 +188,14 @@ list.
|
|||||||
the whole file again, globs the device directories again, and swaps in the new `users`,
|
the whole file again, globs the device directories again, and swaps in the new `users`,
|
||||||
`tiers`, `services` and device lists in one step. Open CDM sessions and remote sessions
|
`tiers`, `services` and device lists in one step. Open CDM sessions and remote sessions
|
||||||
continue; an API key you removed gets `401` on its next request. A file that does not parse
|
continue; an API key you removed gets `401` on its next request. A file that does not parse
|
||||||
or validate keeps the running settings and logs the reason. A change to `remote_only`,
|
or validate keeps the running settings and logs the reason. Each download job starts in a
|
||||||
`services_refresh_interval`, the first PlayReady device, a `dashboard.key` on a server that
|
new process that reads the file on disk, so a job fails until you correct a rejected file.
|
||||||
started without one, or any command-line flag needs a restart, and the log says so. A reload
|
|
||||||
that removes `dashboard.key` closes the dashboard: its routes answer `404` and an open
|
A change to `remote_only`, `services_refresh_interval`, the first PlayReady device, a
|
||||||
`/api/dashboard/events` connection ends. A new `global_speed_limit` applies to jobs that start after the
|
`dashboard.key` on a server that started without one, or any command-line flag needs a
|
||||||
reload; running jobs keep their share. Windows has no `SIGHUP`: restart the server there.
|
restart, and the log says so. A reload that removes `dashboard.key` closes the dashboard: its
|
||||||
|
routes answer `404` and an open `/api/dashboard/events` connection ends. A new
|
||||||
|
`global_speed_limit` applies to jobs that start after the reload; running jobs keep their share. Windows has no `SIGHUP`: restart the server there.
|
||||||
|
|
||||||
`server_cdm` decides whether the server runs the CDM licensing for that API key. Set it to
|
`server_cdm` decides whether the server runs the CDM licensing for that API key. Set it to
|
||||||
`true` to enable every service, or to a list of service tags to enable only those. It is `false`
|
`true` to enable every service, or to a list of service tags to enable only those. It is `false`
|
||||||
|
|||||||
@@ -73,6 +73,21 @@ def test_invalid_file_keeps_the_running_config(running: tuple[web.Application, P
|
|||||||
assert config.serve["users"] == {"old": {"devices": ["dev"]}}
|
assert config.serve["users"] == {"old": {"devices": ["dev"]}}
|
||||||
|
|
||||||
|
|
||||||
|
def test_config_check_that_exits_is_rejected_not_fatal(
|
||||||
|
running: tuple[web.Application, Path], caplog: pytest.LogCaptureFixture
|
||||||
|
) -> None:
|
||||||
|
app, path = running
|
||||||
|
path.write_text(yaml.safe_dump({"filename_replacements": {"&": None}}), encoding="utf8")
|
||||||
|
|
||||||
|
with caplog.at_level(logging.ERROR, logger=LOG.name):
|
||||||
|
assert _reload(app) is False
|
||||||
|
assert [r.getMessage() for r in caplog.records] == [
|
||||||
|
"Config reload rejected, keeping the running config: filename_replacements must map text to text, not {'&': None}"
|
||||||
|
]
|
||||||
|
assert set(app["config"]["users"]) == {"old", "api"}
|
||||||
|
assert config.serve["users"] == {"old": {"devices": ["dev"]}}
|
||||||
|
|
||||||
|
|
||||||
def test_restart_only_change_is_reported_not_applied(
|
def test_restart_only_change_is_reported_not_applied(
|
||||||
running: tuple[web.Application, Path], caplog: pytest.LogCaptureFixture
|
running: tuple[web.Application, Path], caplog: pytest.LogCaptureFixture
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|||||||
@@ -256,8 +256,8 @@ def reload_config(app: web.Application, *, no_key: bool, serve_widevine: bool, s
|
|||||||
fresh = Config.from_yaml(config_module.config_path)
|
fresh = Config.from_yaml(config_module.config_path)
|
||||||
serve = fresh.serve
|
serve = fresh.serve
|
||||||
api_secret = _prepare_serve(serve, no_key, fresh)
|
api_secret = _prepare_serve(serve, no_key, fresh)
|
||||||
except Exception as e:
|
except (Exception, SystemExit) as e:
|
||||||
log.error(f"Config reload rejected, keeping the running config: {e}")
|
log.error(f"Config reload rejected, keeping the running config: {str(e).removeprefix('ERROR: ')}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
changed = [k for k in RESTART_KEYS if serve.get(k) != config.serve.get(k)]
|
changed = [k for k in RESTART_KEYS if serve.get(k) != config.serve.get(k)]
|
||||||
|
|||||||
Reference in New Issue
Block a user