[enh] support restart

This commit is contained in:
Laurent Peuch 2018-07-13 21:46:27 +02:00
parent 974354db4c
commit 10d9490015

12
run.py
View file

@ -30,6 +30,15 @@ COMMUNITY_APPS_LIST = "https://app.yunohost.org/community.json"
APPS_LIST = [OFFICAL_APPS_LIST, COMMUNITY_APPS_LIST]
def reset_pending_jobs():
Job.update(state="scheduled").where(Job.state == "running").execute()
def reset_busy_workers():
# XXX when we'll have distant workers that might break those
Worker.update(state="available").execute()
async def initialize_app_list():
if not os.path.exists("lists"):
os.makedirs("lists")
@ -208,6 +217,9 @@ async def index(request):
if __name__ == "__main__":
subscriptions = defaultdict(list)
reset_pending_jobs()
reset_busy_workers()
app.add_task(initialize_app_list())
app.add_task(jobs_dispatcher())
app.run('localhost', port=5000, debug=True)