def run(self): self.backend = Backend().init() if not self.backend: return if not Auth().init(): return Launchy.attach_loop(self.loop) worker = Worker() self.task_worker = asyncio.ensure_future(worker.run()) backend_worker = BackendWorker() self.task_backend_worker = asyncio.ensure_future(backend_worker.run()) aptly_worker = AptlyWorker() self.task_aptly_worker = asyncio.ensure_future(aptly_worker.run()) notification_worker = NotificationWorker() self.task_notification_worker = asyncio.ensure_future(notification_worker.run()) cfg = Configuration() daily_cleanup = cfg.aptly.get("daily_cleanup") if daily_cleanup is False or daily_cleanup == "off" or daily_cleanup == "disabled": return if not daily_cleanup: daily_cleanup = "04:00" cleanup_sched = Scheduler(locale="en_US") cleanup_job = CronJob(name='cleanup').every().day.at(daily_cleanup).go(self.cleanup_task) cleanup_sched.add_job(cleanup_job) self.task_cron = asyncio.ensure_future(cleanup_sched.start()) app.set_context_functions(MoliorServer.create_cirrina_context, MoliorServer.destroy_cirrina_context) app.run(self.host, self.port, logger=self.logger, debug=self.debug)
def destroy_cirrina_context(cirrina): cirrina.db_session.close() @click.command() @click.option("--host", default="localhost", help="Hostname, examples: 'localhost' or '0.0.0.0'") @click.option("--port", default=8888, help="Listen port") @click.option("--debug", default=False, help="Enable debug") def mainloop(host, port, debug): """ Starts the molior-web app. """ moliorapi.set_context_functions(create_cirrina_context, destroy_cirrina_context) moliorapi.run(host, port, debug=debug) if __name__ == "__main__": logger.info("molior v%s", MOLIOR_VERSION) Launchy.attach_loop(loop) backend = Backend().init(backend_queue) if not backend: exit(1) if not Auth().init(): exit(1) asyncio.ensure_future(main(backend)) mainloop() # pylint: disable=no-value-for-parameter