diff --git a/.dockerignore b/.dockerignore index ac34fea..18d0979 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,4 @@ env .git **/__pycache__ +q diff --git a/.gitignore b/.gitignore index 8f2efa5..7700326 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ env **/__pycache__ +q diff --git a/Dockerfile b/Dockerfile index 6a0d9be..bb3b8bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,4 +13,4 @@ RUN apt update && apt install -y ffmpeg libsm6 libxext6 COPY src . COPY best.pt /best.pt -CMD [ "gunicorn", "-b 0.0.0.0:80", "app:app" ] +CMD [ "gunicorn", "-b 0.0.0.0:80", "--workers", "1", "app:app" ] diff --git a/docker-compose.yml b/docker-compose.yml index 3f7b541..18c6e7b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,4 +5,4 @@ services: build: . restart: unless-stopped ports: - - 8759:8000 + - 8759:80 diff --git a/index.html b/index.html index 129f489..8a7854e 100644 --- a/index.html +++ b/index.html @@ -10,7 +10,7 @@
submit an image to get started!
- @@ -38,11 +38,11 @@ console.log(id); while (true) { - const resp = await fetch('http://localhost:5000/state/' + id); + const resp = await fetch('http://localhost:8759/state/' + id); const state = (await resp.json()).state; statusline.innerHTML = state; if (state == "READY") { - img.src = 'http://localhost:5000/result/' + id + img.src = 'http://localhost:8759/result/' + id return; } } diff --git a/src/app.py b/src/app.py index 15bf620..2440015 100755 --- a/src/app.py +++ b/src/app.py @@ -44,7 +44,7 @@ def process(): print("waiting for/getting job") job = q.get() filepath = root.joinpath(job) - print("got job") + print("got job", flush=True) state[job] = { 'state': QUEUE_STATE_PROCESSING, } @@ -65,6 +65,10 @@ def process(): last = time.time() +p = Thread(target=process) +p.start() + + @app.route("/submit", methods=['POST']) def render(): id = str(uuid.uuid4()) @@ -87,7 +91,4 @@ def get_result(i): if __name__ == '__main__': - p = Thread(target=process) - p.start() app.run(debug=True) - p.join()