Skip to content

Commit

Permalink
Implement GC cfg.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhsamuel committed Dec 16, 2024
1 parent 82740bf commit 800c875
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions python/apsis/ctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,26 @@ def cmd_restart(args):
# command: serve

def cmd_serve(args):
# Assemble config.
cfg = apsis.config.load(args.config)
for ovr in args.override:
name, val = ovr.split("=", 1)
apsis.lib.json.set_dotted(cfg, name, val)

# Configure Python GC.
cfg_gc = cfg.get("python", {}).get("gc", {})
(gc.enable if bool(cfg_gc.get("enabled", True)) else gc.disable)()
try:
gc_threshold = cfg_gc["threshold"]
except KeyError:
pass
else:
gc.set_threshold(*gc_threshold)
log.info(
f"GC {'enabled' if gc.isenabled() else 'disabled'}; "
f"threshold: {gc.get_threshold()}"
)

restart = apsis.service.main.serve(
cfg, host=args.host, port=args.port, debug=args.debug)

Expand Down

0 comments on commit 800c875

Please sign in to comment.