{"record":{"id":"6c6fd6ddd30c2a23","repo":"stamparm/maltrail","slug":"sigterm","errorCode":null,"errorMessage":"SIGTERM","messagePattern":"SIGTERM","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"core/log.py","lineNumber":643,"sourceCode":"        LogUDPServer.address_family = socket.AF_INET6\n        _address = resolve_address(address, port)\n    else:\n        _address = (address or '', int(port) if str(port or \"\").isdigit() else 0)\n\n    server = LogUDPServer(_address, UDPHandler)\n\n    print(\"[i] running UDP server at '%s:%d'\" % (server.server_address[0], server.server_address[1]))\n\n    if join:\n        server.serve_forever()\n    else:\n        thread = threading.Thread(target=server.serve_forever)\n        thread.daemon = True\n        thread.start()\n\ndef set_sigterm_handler():\n    def handler(signum, frame):\n        log_error(\"SIGTERM\")\n        raise SystemExit\n\n    if hasattr(signal, \"SIGTERM\"):\n        signal.signal(signal.SIGTERM, handler)\n\nif __name__ != \"__main__\":\n    set_sigterm_handler()\n","sourceCodeStart":625,"sourceCodeEnd":651,"githubUrl":"https://github.com/stamparm/maltrail/blob/77cfb06d7606506d101bbcec0786c77166c4255e/core/log.py#L625-L651","documentation":"Maltrail installs a SIGTERM signal handler that logs the literal message \"SIGTERM\" via log_error and raises SystemExit to shut down cleanly. The \"SIGTERM\" error entry is therefore a deliberate audit trail: the process received a termination signal (SIGTERM) from outside, not an internal fault.","triggerScenarios":"Sending `kill <pid>` (default SIGTERM) to the Maltrail process; systemd/docker stop issuing SIGTERM during service shutdown or restart; orchestrators terminating pods; `pkill maltrail`.","commonSituations":"Investigating why the sensor stopped and finding this entry — it means someone or something asked it to stop: systemd restart timers, OOM-adjacent cleanup scripts, container lifecycle, or manual ops actions.","solutions":["If unexpected, find the sender: check `journalctl` for systemd stop/restart, `docker events`, or audit logs for the kill source.","Use `kill -TERM` deliberately for graceful shutdown; avoid `kill -9` which bypasses cleanup.","If the process should survive logrotate or deploys, configure the service manager to restart it or use reload signals instead.","Treat this entry as informational when it coincides with a planned shutdown."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    run_sensor()\nexcept SystemExit:\n    log.info('maltrail stopped (SIGTERM)'); flush_state()  # graceful cleanup","preventionTips":["Coordinate restarts with your service manager instead of ad-hoc kills","Use systemctl restart / docker stop so SIGTERM-based cleanup runs","Alert on SIGTERM log entries outside maintenance windows to catch unexpected terminations"],"tags":["python","signals","shutdown","systemd"],"backgroundTag":"sigterm-received","analyzedSha":"77cfb06d7606506d101bbcec0786c77166c4255e","analyzedAt":"2026-09-13T03:50:16.010Z","contentChangedAt":"2026-09-13T03:50:16.010Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}