Skip to content

Commit

Permalink
Merge pull request #297 from aiven/fix-rest-and-registry-shutdown
Browse files Browse the repository at this point in the history
Fix REST and schema registry shutdown
  • Loading branch information
tvainika authored Dec 20, 2021
2 parents 432733f + f4d0cff commit 7f542c8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 5 additions & 0 deletions karapace/karapace.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ def __init__(self, config: dict) -> None:
self.app.on_startup.append(self.create_http_client)
self.master_lock = asyncio.Lock()
self.log.info("Karapace initialized")
self.app.on_shutdown.append(self.close_by_app)

async def close_by_app(self, app):
# pylint: disable=unused-argument
await self.close()

def _create_producer(self) -> KafkaProducer:
while True:
Expand Down
8 changes: 2 additions & 6 deletions karapace/karapace_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ class KarapaceAll(KafkaRest, KarapaceSchemaRegistry):
def __init__(self, config: dict) -> None:
super().__init__(config=config)
self.log = logging.getLogger("KarapaceAll")
self.app.on_shutdown.append(self.close_by_app)

async def close_by_app(self, app):
# pylint: disable=unused-argument
await self.close()


def main() -> int:
Expand Down Expand Up @@ -48,7 +43,8 @@ def main() -> int:
print("Both rest and registry options are disabled, exiting")
return 1

print("=" * 100 + f"\nStarting {info_str}\n" + "=" * 100)
info_str_separator = "=" * 100
logging.log(logging.INFO, "\n%s\nStarting %s\n%s", info_str_separator, info_str, info_str_separator)

try:
kc.run(host=kc.config["host"], port=kc.config["port"])
Expand Down

0 comments on commit 7f542c8

Please sign in to comment.