# something wrong happened, let's be loud about it
raise
- # We could remove the configuration, but there is actually no specific need to do so.
- # If we leave it behind, someone might find it and use it to start us from scratch again,
- # which is perfectly fine.
- # supervisord_config_file(config).unlink()
+ # It is always better to clean up.
+ # This way, we can be sure that we are starting with a newly generated configuration.
+ supervisord_config_file(config).unlink()
async def _is_supervisord_available() -> bool:
while not self._is_policy_loader_exited():
await asyncio.sleep(1)
+ # Clean up policy-loader configuration.
+ # If we don't do this, we may start with
+ # an old configuration and fail to detect a bug.
+ if self._policy_loader:
+ await self._policy_loader.cleanup()
+
except (SubprocessError, SubprocessControllerError) as e:
logger.error(f"Failed to load policy rules: {e}")
return Result.err("kresd 'policy-loader' process failed to start. Config might be invalid.")