else:
self._controller = selected_controller
self._config_store = config_store
+ logger.debug("Starting controller")
await self._controller.initialize_controller(config_store.get())
self._watchdog_task = create_task(self._watchdog())
+ logger.debug("Looking for already running workers")
await self._collect_already_running_workers()
# registering the function calls them immediately, therefore after this, the config is applied
import asyncio
import itertools
+import logging
import sys
from enum import Enum, auto
from typing import Dict, Iterable, Optional, Type, TypeVar
from knot_resolver_manager.statistics import register_resolver_metrics_for, unregister_resolver_metrics_for
from knot_resolver_manager.utils.async_utils import writefile
+logger = logging.getLogger(__name__)
+
class SubprocessType(Enum):
KRESD = auto()
async def apply_new_config(self, new_config: KresConfig) -> None:
self._config = new_config
# update config file
+ logger.debug(f"Writing config file for {self.id}")
lua_config = new_config.render_lua()
await writefile(kresd_config_file(new_config, self.id), lua_config)
# update runtime status
+ logger.debug(f"Restarting {self.id}")
await self._restart()
async def stop(self) -> None:
+import asyncio
import logging
from os import kill
from pathlib import Path
async def _start_supervisord(config: KresConfig) -> None:
+ logger.debug("Writing supervisord config")
await write_config_file(config)
- res = await call(f'supervisord --configuration="{supervisord_config_file(config).absolute()}"', shell=True)
+ logger.debug("Starting supervisord")
+ res = await call(["supervisord", "--configuration", str(supervisord_config_file(config).absolute())])
if res != 0:
raise SubprocessControllerException(f"Supervisord exited with exit code {res}")
async def _is_supervisord_available() -> bool:
- i = await call("supervisorctl -h > /dev/null", shell=True, discard_output=True)
- i += await call("supervisord -h > /dev/null", shell=True, discard_output=True)
- return i == 0
+ i, y = await asyncio.gather(
+ call("supervisorctl -h > /dev/null", shell=True, discard_output=True),
+ call("supervisord -h > /dev/null", shell=True, discard_output=True),
+ )
+ return i + y == 0
async def _get_supervisord_pid(config: KresConfig) -> Optional[int]: