mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
from app import create_app
|
|
from time import sleep
|
|
from ..decorators import background
|
|
import docker
|
|
|
|
|
|
app = create_app()
|
|
docker_client = docker.from_env()
|
|
|
|
app.app_context().push()
|
|
from . import check_corpora, check_jobs, notify # noqa
|
|
|
|
|
|
def run():
|
|
check_corpora_thread = check_corpora()
|
|
check_jobs_thread = check_jobs()
|
|
notify_thread = notify()
|
|
|
|
while True:
|
|
if not check_corpora_thread.is_alive():
|
|
check_corpora_thread = check_corpora()
|
|
if not check_jobs_thread.is_alive():
|
|
check_jobs_thread = check_jobs()
|
|
if not notify_thread.is_alive():
|
|
notify_thread = notify()
|
|
sleep(3)
|
|
|
|
|
|
@background
|
|
def check_corpora():
|
|
corpora = Corpus.query.all()
|
|
for corpus in filter(lambda corpus: corpus.status == 'submitted', corpora):
|
|
__create_build_corpus_service(corpus)
|
|
for corpus in filter(lambda corpus: (corpus.status == 'queued'
|
|
or corpus.status == 'running'),
|
|
corpora):
|
|
__checkout_build_corpus_service(corpus)
|
|
for corpus in filter(lambda corpus: corpus.status == 'start analysis',
|
|
corpora):
|
|
__create_cqpserver_container(corpus)
|
|
for corpus in filter(lambda corpus: corpus.status == 'stop analysis',
|
|
corpora):
|
|
__remove_cqpserver_container(corpus)
|