Change the scaling logic and switch back to the socketio web server

This commit is contained in:
Patrick Jentsch 2022-04-22 16:36:12 +02:00
parent ccdd0d3faa
commit fc1389e8b1
8 changed files with 27 additions and 29 deletions

View File

@ -108,14 +108,14 @@ NOPAQUE_ADMIN=
# Swarm nodes # Swarm nodes
# NOPAQUE_DATA_DIR= # NOPAQUE_DATA_DIR=
# CHOOSE ONE: False, True
# DEFAULT: True
# NOPAQUE_DAEMON_ENABLED=
# NOTE: Get these from the nopaque development team # NOTE: Get these from the nopaque development team
NOPAQUE_DOCKER_REGISTRY_USERNAME= NOPAQUE_DOCKER_REGISTRY_USERNAME=
NOPAQUE_DOCKER_REGISTRY_PASSWORD= NOPAQUE_DOCKER_REGISTRY_PASSWORD=
# CHOOSE ONE: False, True
# DEFAULT: True
# NOPAQUE_IS_PRIMARY_INSTANCE=
# transport://[userid:password]@hostname[:port]/[virtual_host] # transport://[userid:password]@hostname[:port]/[virtual_host]
NOPAQUE_SOCKETIO_MESSAGE_QUEUE_URI= NOPAQUE_SOCKETIO_MESSAGE_QUEUE_URI=

View File

@ -125,8 +125,6 @@ def import_corpus():
db.session.add(corpus_file) db.session.add(corpus_file)
db.session.flush(objects=[corpus_file]) db.session.flush(objects=[corpus_file])
db.session.refresh(corpus) db.session.refresh(corpus)
current_app.logger.warning(vrt_file)
current_app.logger.warning(corpus_file.path)
try: try:
shutil.copy2(vrt_file, corpus_file.path) shutil.copy2(vrt_file, corpus_file.path)
except Exception as e: except Exception as e:

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
source venv/bin/activate source venv/bin/activate
if [[ "${#}" -eq 0 ]]; then if [[ "${#}" -eq 0 ]]; then
if [[ "${NOPAQUE_IS_PRIMARY_INSTANCE:-True}" == "True" ]]; then
while true; do while true; do
echo "INFO Run deployment tasks..." echo "INFO Run deployment tasks..."
flask deploy flask deploy
@ -10,17 +11,11 @@ if [[ "${#}" -eq 0 ]]; then
echo "WARNING ...Failed, retrying in 5 secs..." echo "WARNING ...Failed, retrying in 5 secs..."
sleep 5 sleep 5
done done
if [[ "${NOPAQUE_DAEMON_ENABLED:-True}" == "True" ]]; then
echo "INFO Start nopaque daemon..." echo "INFO Start nopaque daemon..."
flask daemon run & flask daemon run &
fi fi
echo "INFO Start nopaque..." echo "INFO Start nopaque..."
gunicorn \ python nopaque.py
--error-logfile - \
$([ "${ENABLE_GUNICORN_RELOAD:-False}" == "True" ] && echo "--reload") \
--worker-class eventlet \
-b :5000 \
-w 1 nopaque:app
elif [[ "${1}" == "flask" ]]; then elif [[ "${1}" == "flask" ]]; then
exec ${@:1} exec ${@:1}
else else

View File

@ -47,8 +47,8 @@ class Config:
''' # nopaque # ''' ''' # nopaque # '''
NOPAQUE_ADMIN = os.environ.get('NOPAQUE_ADMIN') NOPAQUE_ADMIN = os.environ.get('NOPAQUE_ADMIN')
NOPAQUE_DAEMON_ENABLED = \ NOPAQUE_IS_PRIMARY_INSTANCE = \
os.environ.get('NOPAQUE_DAEMON_ENABLED', 'true').lower() == 'true' os.environ.get('NOPAQUE_IS_PRIMARY_INSTANCE', 'true').lower() == 'true'
NOPAQUE_DATA_DIR = \ NOPAQUE_DATA_DIR = \
os.path.abspath(os.environ.get('NOPAQUE_DATA_DIR', '/mnt/nopaque')) os.path.abspath(os.environ.get('NOPAQUE_DATA_DIR', '/mnt/nopaque'))
NOPAQUE_DOCKER_REGISTRY = 'gitlab.ub.uni-bielefeld.de:4567' NOPAQUE_DOCKER_REGISTRY = 'gitlab.ub.uni-bielefeld.de:4567'

View File

@ -2,8 +2,6 @@ version: "3.5"
services: services:
nopaque: nopaque:
environment:
- ENABLE_GUNICORN_RELOAD=True
ports: ports:
- "5000:5000" - "5000:5000"
volumes: volumes:

View File

@ -3,4 +3,4 @@ version: "3.5"
services: services:
nopaque: nopaque:
environment: environment:
- NOPAQUE_DAEMON_ENABLED=False - NOPAQUE_IS_PRIMARY_INSTANCE=False

View File

@ -3,7 +3,7 @@
import eventlet import eventlet
eventlet.monkey_patch() eventlet.monkey_patch()
from app import db, cli, create_app # noqa from app import db, cli, create_app, socketio # noqa
from app.models import ( from app.models import (
Corpus, Corpus,
CorpusFile, CorpusFile,
@ -46,3 +46,11 @@ def make_shell_context() -> Dict[str, Any]:
'TranskribusHTRModel': TranskribusHTRModel, 'TranskribusHTRModel': TranskribusHTRModel,
'User': User 'User': User
} }
def main():
socketio.run(app, host='0.0.0.0')
if __name__ == '__main__':
main()

View File

@ -14,7 +14,6 @@ Flask-RESTX
Flask-SocketIO~=5.1 Flask-SocketIO~=5.1
Flask-SQLAlchemy Flask-SQLAlchemy
Flask-WTF Flask-WTF
gunicorn
hiredis hiredis
jsonschema jsonschema
MarkupSafe==2.0.1 MarkupSafe==2.0.1