def run(cls, store, master_options):
gobject.threads_init()
dbus.glib.init_threads()
DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
name = dbus.service.BusName("com.airbus.rebus.bus", bus)
svc = cls(bus, "/bus", store)
svc.mainloop = gobject.MainLoop()
log.info("Entering main loop.")
try:
svc.mainloop.run()
except (KeyboardInterrupt, SystemExit):
if len(svc.clients) > 0:
log.info("Trying to stop all agents properly. Press Ctrl-C "
"again to stop.")
# stop scheduler
svc.sched.shutdown()
# ask slave agents to shutdown nicely & save internal state
log.info("Expecting %u more agents to exit (ex. %s)",
len(svc.clients), svc.clients.keys()[0])
svc.bus_exit(store.STORES_INTSTATE)
store.store_state()
try:
svc.mainloop.run()
except (KeyboardInterrupt, SystemExit):
if len(svc.clients) > 0:
log.info(
"Not all agents have stopped, exiting nonetheless")
log.info("Stopping storage...")
store.store_state()
评论列表
文章目录