Move more things out of FrigateApp (#13897)

* Moved FrigateApp.init_config() into FrigateConfig.load()

* Move frigate config loading into main

* Store PlusApi in FrigateConfig

* Register SIGTERM handler in main

* Ensure logging is setup during config parsing

* Removed pointless try

* Moved config initialization out of FrigateApp

* Made FrigateApp.shm_frame_count into a function

* Removed log calls from signal handlers

python's logging calls are not re-entrant, which caused at least one of
these to deadlock randomly.

* Reopen stdout/err on process fork

This helps avoid deadlocks (https://github.com/python/cpython/issues/91776).

* Make mypy happy

* Whoops. I might have forgotten to save.

Truly an amateur mistake.

* Always call FrigateApp.stop()
This commit is contained in:
gtsiam
2024-09-24 15:07:47 +03:00
committed by GitHub
parent a7ed90f042
commit dc54981784
15 changed files with 215 additions and 213 deletions

View File

@@ -13,7 +13,6 @@ from playhouse.sqliteq import SqliteQueueDatabase
from frigate.api.app import create_app
from frigate.config import FrigateConfig
from frigate.models import Event, Recordings
from frigate.plus import PlusApi
from frigate.stats.emitter import StatsEmitter
from frigate.test.const import TEST_DB, TEST_DB_CLEANUPS
@@ -121,7 +120,6 @@ class TestHttp(unittest.TestCase):
None,
None,
None,
PlusApi(),
None,
)
id = "123456.random"
@@ -158,7 +156,6 @@ class TestHttp(unittest.TestCase):
None,
None,
None,
PlusApi(),
None,
)
id = "123456.random"
@@ -180,7 +177,6 @@ class TestHttp(unittest.TestCase):
None,
None,
None,
PlusApi(),
None,
)
id = "123456.random"
@@ -201,7 +197,6 @@ class TestHttp(unittest.TestCase):
None,
None,
None,
PlusApi(),
None,
)
id = "123456.random"
@@ -224,7 +219,6 @@ class TestHttp(unittest.TestCase):
None,
None,
None,
PlusApi(),
None,
)
id = "123456.random"
@@ -251,7 +245,6 @@ class TestHttp(unittest.TestCase):
None,
None,
None,
PlusApi(),
None,
)
morning_id = "123456.random"
@@ -290,7 +283,6 @@ class TestHttp(unittest.TestCase):
None,
None,
None,
PlusApi(),
None,
)
id = "123456.random"
@@ -326,7 +318,6 @@ class TestHttp(unittest.TestCase):
None,
None,
None,
PlusApi(),
None,
)
id = "123456.random"
@@ -352,7 +343,6 @@ class TestHttp(unittest.TestCase):
None,
None,
None,
PlusApi(),
None,
)
@@ -370,7 +360,6 @@ class TestHttp(unittest.TestCase):
None,
None,
None,
PlusApi(),
None,
)
id = "123456.random"
@@ -392,7 +381,6 @@ class TestHttp(unittest.TestCase):
None,
None,
None,
PlusApi(),
stats,
)