blakeblackshear.frigate/frigate
gtsiam 4bb420d049
Add service manager infrastructure (#14150)
* Add service manager infrastructure

The changes are (This will be a bit long):
- A ServiceManager class that spawns a background thread and deals with
  service lifecycle management. The idea is that service lifecycle code
  will run in async functions, so a single thread is enough to manage
  any (reasonable) amount of services.

- A Service class, that offers start(), stop() and restart() methods
  that simply notify the service manager to... well. Start, stop or
  restart a service.

(!) Warning: Note that this differs from mp.Process.start/stop in that
  the service commands are sent asynchronously and will complete
  "eventually". This is good because it means that business logic is
  fast when booting up and shutting down, but we need to make sure
  that code does not rely on start() and stop() being instant
  (Mainly pid assignments).

  Subclasses of the Service class should use the on_start and on_stop
  methods to monitor for service events. These will be run by the
  service manager thread, so we need to be careful not to block
  execution here. Standard async stuff.

(!) Note on service names: Service names should be unique within a
  ServiceManager. Make sure that you pass the name you want to
  super().__init__(name="...") if you plan to spawn multiple instances
  of a service.

- A ServiceProcess class: A Service that wraps a multiprocessing.Process
  into a Service. It offers a run() method subclasses can override and
  can support in-place restarting using the service manager.

And finally, I lied a bit about this whole thing using a single thread.
I can't find any way to run python multiprocessing in async, so there is
a MultiprocessingWaiter thread that waits for multiprocessing events and
notifies any pending futures. This was uhhh... fun? No, not really.
But it works. Using this part of the code just involves calling the
provided wait method. See the implementation of ServiceProcess for more
details.

Mirror util.Process hooks onto service process

Remove Service.__name attribute

Do not serialize process object on ServiceProcess start.

asd

* Update frigate dictionary

* Convert AudioProcessor to service process
2024-10-21 10:00:38 -05:00
..
api Improve Explore SQL query memory usage (#14451) 2024-10-19 22:12:54 -06:00
camera Custom classes for Process and Metrics (#13950) 2024-09-27 07:53:23 -05:00
comms Search UI tweaks and bugfixes (#14328) 2024-10-13 19:36:49 -06:00
config Generative AI changes (#14413) 2024-10-17 10:15:44 -06:00
db Embeddings normalization fixes (#14284) 2024-10-11 13:11:11 -05:00
detectors Update logos handling (#14396) 2024-10-16 16:22:34 -05:00
embeddings Misc bugfixes and improvements (#14460) 2024-10-20 14:14:51 -06:00
events Add service manager infrastructure (#14150) 2024-10-21 10:00:38 -05:00
genai Fix genai labels (#14330) 2024-10-14 06:23:10 -06:00
images
motion Work through most of the cspell warnings in python (#13794) 2024-09-17 10:41:46 -05:00
output Properly call super() in subclasses (#14124) 2024-10-02 19:35:46 -06:00
ptz Fix autotrack to work with new tracked object package (#14414) 2024-10-17 10:21:27 -06:00
record Don't allow unlimited unprocessed segments to stay in cache (#14341) 2024-10-14 16:11:43 -06:00
review Bug fixes (#14263) 2024-10-10 07:09:12 -06:00
service_manager Add service manager infrastructure (#14150) 2024-10-21 10:00:38 -05:00
stats Properly call super() in subclasses (#14124) 2024-10-02 19:35:46 -06:00
test Various fixes (#14410) 2024-10-17 11:02:27 -05:00
track Various fixes (#14410) 2024-10-17 11:02:27 -05:00
util Fixes (#14480) 2024-10-21 09:38:48 -05:00
__init__.py
__main__.py Split config.py into multiple files (#14038) 2024-09-28 14:21:42 -05:00
app.py Add service manager infrastructure (#14150) 2024-10-21 10:00:38 -05:00
const.py Update logos handling (#14396) 2024-10-16 16:22:34 -05:00
ffmpeg_presets.py Bug Fixes (#14193) 2024-10-07 07:18:09 -06:00
log.py Properly call super() in subclasses (#14124) 2024-10-02 19:35:46 -06:00
models.py Implement support for notifications (#12523) 2024-08-29 20:19:50 -06:00
mypy.ini Add service manager infrastructure (#14150) 2024-10-21 10:00:38 -05:00
object_detection.py Improve rocm handling of different models (#14072) 2024-09-30 16:40:46 -05:00
object_processing.py Fixes (#14480) 2024-10-21 09:38:48 -05:00
plus.py strip whitespaces when loading secrets (#12393) 2024-07-12 07:36:15 -06:00
storage.py Properly call super() in subclasses (#14124) 2024-10-02 19:35:46 -06:00
timeline.py Properly call super() in subclasses (#14124) 2024-10-02 19:35:46 -06:00
types.py Use sqlite-vec extension instead of chromadb for embeddings (#14163) 2024-10-07 14:30:45 -06:00
video.py Various fixes (#14410) 2024-10-17 11:02:27 -05:00
watchdog.py Properly call super() in subclasses (#14124) 2024-10-02 19:35:46 -06:00