diff --git a/.env.tpl b/.env.tpl index 07db6275..ff483e97 100644 --- a/.env.tpl +++ b/.env.tpl @@ -108,14 +108,14 @@ NOPAQUE_ADMIN= # Swarm nodes # NOPAQUE_DATA_DIR= -# CHOOSE ONE: False, True -# DEFAULT: True -# NOPAQUE_DAEMON_ENABLED= - # NOTE: Get these from the nopaque development team NOPAQUE_DOCKER_REGISTRY_USERNAME= NOPAQUE_DOCKER_REGISTRY_PASSWORD= +# CHOOSE ONE: False, True +# DEFAULT: True +# NOPAQUE_IS_PRIMARY_INSTANCE= + # transport://[userid:password]@hostname[:port]/[virtual_host] NOPAQUE_SOCKETIO_MESSAGE_QUEUE_URI= diff --git a/app/corpora/routes.py b/app/corpora/routes.py index b6bf2d01..3a3c76e3 100644 --- a/app/corpora/routes.py +++ b/app/corpora/routes.py @@ -125,8 +125,6 @@ def import_corpus(): db.session.add(corpus_file) db.session.flush(objects=[corpus_file]) db.session.refresh(corpus) - current_app.logger.warning(vrt_file) - current_app.logger.warning(corpus_file.path) try: shutil.copy2(vrt_file, corpus_file.path) except Exception as e: diff --git a/boot.sh b/boot.sh index 6cd26836..68765e62 100755 --- a/boot.sh +++ b/boot.sh @@ -1,26 +1,21 @@ #!/bin/bash source venv/bin/activate if [[ "${#}" -eq 0 ]]; then - while true; do - echo "INFO Run deployment tasks..." - flask deploy - if [[ "${?}" == "0" ]]; then - break - fi - echo "WARNING ...Failed, retrying in 5 secs..." - sleep 5 - done - if [[ "${NOPAQUE_DAEMON_ENABLED:-True}" == "True" ]]; then + if [[ "${NOPAQUE_IS_PRIMARY_INSTANCE:-True}" == "True" ]]; then + while true; do + echo "INFO Run deployment tasks..." + flask deploy + if [[ "${?}" == "0" ]]; then + break + fi + echo "WARNING ...Failed, retrying in 5 secs..." + sleep 5 + done echo "INFO Start nopaque daemon..." flask daemon run & fi echo "INFO Start nopaque..." - gunicorn \ - --error-logfile - \ - $([ "${ENABLE_GUNICORN_RELOAD:-False}" == "True" ] && echo "--reload") \ - --worker-class eventlet \ - -b :5000 \ - -w 1 nopaque:app + python nopaque.py elif [[ "${1}" == "flask" ]]; then exec ${@:1} else diff --git a/config.py b/config.py index 07ec1d78..d8d12fa7 100644 --- a/config.py +++ b/config.py @@ -47,8 +47,8 @@ class Config: ''' # nopaque # ''' NOPAQUE_ADMIN = os.environ.get('NOPAQUE_ADMIN') - NOPAQUE_DAEMON_ENABLED = \ - os.environ.get('NOPAQUE_DAEMON_ENABLED', 'true').lower() == 'true' + NOPAQUE_IS_PRIMARY_INSTANCE = \ + os.environ.get('NOPAQUE_IS_PRIMARY_INSTANCE', 'true').lower() == 'true' NOPAQUE_DATA_DIR = \ os.path.abspath(os.environ.get('NOPAQUE_DATA_DIR', '/mnt/nopaque')) NOPAQUE_DOCKER_REGISTRY = 'gitlab.ub.uni-bielefeld.de:4567' diff --git a/docker-compose.development.yml b/docker-compose.development.yml index 7192dd78..564eae38 100644 --- a/docker-compose.development.yml +++ b/docker-compose.development.yml @@ -2,8 +2,6 @@ version: "3.5" services: nopaque: - environment: - - ENABLE_GUNICORN_RELOAD=True ports: - "5000:5000" volumes: diff --git a/docker-compose.scale.yml b/docker-compose.scale.yml index f13b3550..bc9154fc 100644 --- a/docker-compose.scale.yml +++ b/docker-compose.scale.yml @@ -3,4 +3,4 @@ version: "3.5" services: nopaque: environment: - - NOPAQUE_DAEMON_ENABLED=False + - NOPAQUE_IS_PRIMARY_INSTANCE=False diff --git a/nopaque.py b/nopaque.py index 0f2d0d2a..8eb4d3bb 100644 --- a/nopaque.py +++ b/nopaque.py @@ -3,7 +3,7 @@ import eventlet eventlet.monkey_patch() -from app import db, cli, create_app # noqa +from app import db, cli, create_app, socketio # noqa from app.models import ( Corpus, CorpusFile, @@ -46,3 +46,11 @@ def make_shell_context() -> Dict[str, Any]: 'TranskribusHTRModel': TranskribusHTRModel, 'User': User } + + +def main(): + socketio.run(app, host='0.0.0.0') + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 038611ce..60a4aaf0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,7 +14,6 @@ Flask-RESTX Flask-SocketIO~=5.1 Flask-SQLAlchemy Flask-WTF -gunicorn hiredis jsonschema MarkupSafe==2.0.1