mirror of
https://github.com/YunoHost/yunorunner.git
synced 2024-09-03 20:05:52 +02:00
[enh] support restart
This commit is contained in:
parent
974354db4c
commit
10d9490015
1 changed files with 12 additions and 0 deletions
12
run.py
12
run.py
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue