mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-08-02 17:12:16 +03:00
Handle SIGINT with forkserver (#18860)
* Pass stopevent from main start * Share stop event across processes * preload modules * remove explicit os._exit call --------- Co-authored-by: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com>
This commit is contained in:
committed by
Blake Blackshear
co-authored by
Josh Hawkins
parent
e1ee6f010f
commit
542bf05bb8
+19
-1
@@ -23,6 +23,10 @@ def main() -> None:
|
||||
setup_logging(manager)
|
||||
|
||||
threading.current_thread().name = "frigate"
|
||||
stop_event = mp.Event()
|
||||
|
||||
# send stop event on SIGINT
|
||||
signal.signal(signal.SIGINT, lambda sig, frame: stop_event.set())
|
||||
|
||||
# Make sure we exit cleanly on SIGTERM.
|
||||
signal.signal(signal.SIGTERM, lambda sig, frame: sys.exit())
|
||||
@@ -110,9 +114,23 @@ def main() -> None:
|
||||
sys.exit(0)
|
||||
|
||||
# Run the main application.
|
||||
FrigateApp(config, manager).start()
|
||||
FrigateApp(config, manager, stop_event).start()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
mp.set_forkserver_preload(
|
||||
[
|
||||
# Standard library and core dependencies
|
||||
"sqlite3",
|
||||
# Third-party libraries commonly used in Frigate
|
||||
"numpy",
|
||||
"cv2",
|
||||
"peewee",
|
||||
"zmq",
|
||||
"ruamel.yaml",
|
||||
# Frigate core modules
|
||||
"frigate.camera.maintainer",
|
||||
]
|
||||
)
|
||||
mp.set_start_method("forkserver", force=True)
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user