| 48 | return cls._instance |
| 49 | |
| 50 | def __init__(self) -> None: |
| 51 | self.plugins_dir = os.environ.get("DISPATCHARR_PLUGINS_DIR", "/data/plugins") |
| 52 | self._registry: Dict[str, LoadedPlugin] = {} |
| 53 | self._package_names: Dict[str, str] = {} |
| 54 | self._alias_names: Dict[str, str] = {} |
| 55 | self._reload_token_path = os.path.join(self.plugins_dir, ".reload_token") |
| 56 | self._last_reload_token = 0.0 |
| 57 | self._discovery_completed = False |
| 58 | self._lock = threading.RLock() |
| 59 | |
| 60 | # Ensure plugins directory exists |
| 61 | os.makedirs(self.plugins_dir, exist_ok=True) |
| 62 | if self.plugins_dir not in sys.path: |
| 63 | sys.path.append(self.plugins_dir) |
| 64 | |
| 65 | def discover_plugins( |
| 66 | self, |