Skip to content

Commit

Permalink
Merge pull request #6 from desultory/dev
Browse files Browse the repository at this point in the history
add startup task definition
  • Loading branch information
desultory authored Feb 10, 2025
2 parents 3d37ccd + 2820777 commit eca3014
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "prometheus_exporter"
version = "1.2.0"
version = "1.3.0"
authors = [
{ name="Desultory", email="[email protected]" },
]
Expand Down
4 changes: 4 additions & 0 deletions src/prometheus_exporter/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def __init__(self, config_file="config.toml", name=None, labels=Labels(), no_con

self.app = Application(logger=self.logger)
signal(SIGINT, lambda *args: ensure_future(self.app.shutdown()))
self.app.on_startup.append(self.startup_tasks)
self.app.add_routes([get("/metrics", self.handle_metrics)])
self.app.on_shutdown.append(self.on_shutdown)

Expand Down Expand Up @@ -78,6 +79,9 @@ def start(self):
self.logger.info("Exporter server address: %s:%d" % (self.listen_ip, self.listen_port))
web.run_app(self.app, host=self.listen_ip, port=self.listen_port)

async def startup_tasks(self, *args, **kwargs):
pass

async def on_shutdown(self, app):
self.logger.info("Shutting down exporter server")
for task in all_tasks():
Expand Down

0 comments on commit eca3014

Please sign in to comment.