diff --git a/platypush/__init__.py b/platypush/__init__.py index c6750c3a2..fb4de4d25 100644 --- a/platypush/__init__.py +++ b/platypush/__init__.py @@ -19,6 +19,7 @@ from .context import register_backends from .cron.scheduler import CronScheduler from .event.processor import EventProcessor from .message.event import Event, StopEvent +from .message.event.application import ApplicationStartedEvent, ApplicationStoppedEvent from .message.request import Request from .message.response import Response @@ -113,6 +114,7 @@ class Daemon: def stop_app(self): """ Stops the backends and the bus """ + self.bus.post(ApplicationStoppedEvent()) for backend in self.backends.values(): backend.stop() self.bus.stop() @@ -133,6 +135,8 @@ class Daemon: if Config.get_cronjobs(): CronScheduler(jobs=Config.get_cronjobs()).start() + self.bus.post(ApplicationStartedEvent()) + # Poll for messages on the bus try: self.bus.poll() diff --git a/platypush/message/event/application.py b/platypush/message/event/application.py new file mode 100644 index 000000000..40adbc7d3 --- /dev/null +++ b/platypush/message/event/application.py @@ -0,0 +1,23 @@ +from platypush.message.event import Event + + +class ApplicationStartedEvent(Event): + """ + Event triggered when the application has started and all the backends have been registered + """ + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + +class ApplicationStoppedEvent(Event): + """ + Event triggered when the application stops + """ + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + +# vim:sw=4:ts=4:et: +