-1

I am trying to run my app on back4app and has the following issue:

2023-05-07T11:39:43.342Z SYSTEM LAUNCHING CONTAINER...

2023-05-07T11:39:46.143Z SYSTEM CHECKING HEALTH...

2023-05-07T11:39:46.144Z SYSTEM trying to hit the 8080 port using http

2023-05-07T11:39:46.151Z SYSTEM it looks that no process is listening to the 8080 port using http

2023-05-07T11:39:46.153Z SYSTEM trying again in 1s

2023-05-07T11:39:47.154Z SYSTEM trying to hit the 8080 port using http

2023-05-07T11:39:47.157Z SYSTEM it looks that no process is listening to the 8080 port using http

2023-05-07T11:39:47.159Z SYSTEM trying again in 2s

2023-05-07T11:39:49.159Z SYSTEM trying to hit the 8080 port using http

2023-05-07T11:39:52.162Z SYSTEM http request to the 8080 port timed out after 3s

2023-05-07T11:39:52.166Z SYSTEM The container exited before becoming healthy. Please check the container logs.

2023-05-07T11:39:52.167Z SYSTEM deployment failed

My dockerfile :

FROM python:3.9-slim

WORKDIR /app

COPY requirements.txt requirements.txt RUN pip install --no-cache-dir -r requirements.txt

COPY . .

EXPOSE 8080

CMD ["gunicorn", "-b", "0.0.0.0:8080", "app:app"]

Flask run:

if name == "main": app.run(host='0.0.0.0', port=8080)

Requirements.txt:

Flask==2.3.2 Jinja2==3.1.2 MarkupSafe==2.1.2 Werkzeug==2.3.3 blinker==1.6.2 click==8.1.3 colorama==0.4.6 itsdangerous==2.1.2 Flask-Bootstrap==3.3.7.1 dominate==2.7.0 visitor==0.1.3 Flask-CKEditor==0.4.6 Flask-Gravatar==0.5.0 Flask-Login==0.6.2 Flask-SQLAlchemy==3.0.3 SQLAlchemy==2.0.12 greenlet==2.0.2 typing-extensions==4.5.0 Flask-WTF==1.1.1 idna==3.4 charset-normalizer==3.1.0 certifi==2023.5.7 itsdangerous==2.1.2 MarkupSafe==2.1.2 requests==2.30.0 urllib3==2.0.2 WTForms==3.0.1 gunicorn==20.1.0

Container log:

2023-05-07T11:39:46.837Ze1abceaa[2023-05-07 11:39:46 +0000] [1] [INFO] Starting gunicorn 20.1.0

2023-05-07T11:39:46.838Ze1abceaa[2023-05-07 11:39:46 +0000] [1] [INFO] Using worker: sync

2023-05-07T11:39:46.838Ze1abceaa[2023-05-07 11:39:46 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1)

2023-05-07T11:39:46.843Ze1abceaa[2023-05-07 11:39:46 +0000] [7] [INFO] Booting worker with pid: 7

2023-05-07T11:39:46.846Ze1abceaa[2023-05-07 11:39:46 +0000] [7] [INFO] Worker exiting (pid: 7)

2023-05-07T11:39:46.846Ze1abceaaModuleNotFoundError: No module named 'app'

2023-05-07T11:39:46.846Ze1abceaa File "", line 984, in _find_and_load_unlocked

2023-05-07T11:39:46.846Ze1abceaa File "", line 1007, in _find_and_load

2023-05-07T11:39:46.846Ze1abceaa File "", line 1030, in _gcd_import

2023-05-07T11:39:46.846Ze1abceaa return _bootstrap._gcd_import(name[level:], package, level)

2023-05-07T11:39:46.846Ze1abceaa File "/usr/local/lib/python3.9/importlib/init.py", line 127, in import_module

2023-05-07T11:39:46.846Ze1abceaa mod = importlib.import_module(module)

2023-05-07T11:39:46.846Ze1abceaa File "/usr/local/lib/python3.9/site-packages/gunicorn/util.py", line 359, in import_app

2023-05-07T11:39:46.846Ze1abceaa return util.import_app(self.app_uri)

2023-05-07T11:39:46.846Ze1abceaa File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp

2023-05-07T11:39:46.846Ze1abceaa return self.load_wsgiapp()

2023-05-07T11:39:46.846Ze1abceaa File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load

2023-05-07T11:39:46.846Ze1abceaa self.callable = self.load()

2023-05-07T11:39:46.846Ze1abceaa File "/usr/local/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi

2023-05-07T11:39:46.846Ze1abceaa self.wsgi = self.app.wsgi()

2023-05-07T11:39:46.846Ze1abceaa File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi

2023-05-07T11:39:46.846Ze1abceaa self.load_wsgi()

2023-05-07T11:39:46.846Ze1abceaa File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 134, in init_process

2023-05-07T11:39:46.846Ze1abceaa worker.init_process()

2023-05-07T11:39:46.846Ze1abceaa File "/usr/local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker

2023-05-07T11:39:46.846Ze1abceaaTraceback (most recent call last):

2023-05-07T11:39:46.846Ze1abceaa[2023-05-07 11:39:46 +0000] [7] [ERROR] Exception in worker process

2023-05-07T11:39:47.028Ze1abceaa[2023-05-07 11:39:47 +0000] [1] [INFO] Shutting down: Master

2023-05-07T11:39:47.028Ze1abceaa[2023-05-07 11:39:47 +0000] [1] [INFO] Reason: Worker failed to boot.

2023-05-07T13:21:26.458Z8788bd13[2023-05-07 13:21:26 +0000] [1] [INFO] Starting gunicorn 20.1.0

2023-05-07T13:21:26.460Z8788bd13[2023-05-07 13:21:26 +0000] [1] [INFO] Using worker: sync

2023-05-07T13:21:26.460Z8788bd13[2023-05-07 13:21:26 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1)

2023-05-07T13:21:26.528Z8788bd13[2023-05-07 13:21:26 +0000] [7] [INFO] Booting worker with pid: 7

2023-05-07T13:21:26.532Z8788bd13[2023-05-07 13:21:26 +0000] [7] [INFO] Worker exiting (pid: 7)

2023-05-07T13:21:26.532Z8788bd13ModuleNotFoundError: No module named 'app'

2023-05-07T13:21:26.532Z8788bd13 File "", line 984, in _find_and_load_unlocked

2023-05-07T13:21:26.532Z8788bd13 File "", line 1007, in _find_and_load

2023-05-07T13:21:26.532Z8788bd13 File "", line 1030, in _gcd_import

2023-05-07T13:21:26.532Z8788bd13 return _bootstrap._gcd_import(name[level:], package, level)

2023-05-07T13:21:26.532Z8788bd13 File "/usr/local/lib/python3.9/importlib/init.py", line 127, in import_module

2023-05-07T13:21:26.532Z8788bd13 mod = importlib.import_module(module)

2023-05-07T13:21:26.532Z8788bd13 File "/usr/local/lib/python3.9/site-packages/gunicorn/util.py", line 359, in import_app

2023-05-07T13:21:26.532Z8788bd13 return util.import_app(self.app_uri)

2023-05-07T13:21:26.532Z8788bd13 File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp

2023-05-07T13:21:26.532Z8788bd13 return self.load_wsgiapp()

2023-05-07T13:21:26.532Z8788bd13 File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load

2023-05-07T13:21:26.532Z8788bd13 self.callable = self.load()

2023-05-07T13:21:26.532Z8788bd13 File "/usr/local/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi

2023-05-07T13:21:26.532Z8788bd13 self.wsgi = self.app.wsgi()

2023-05-07T13:21:26.532Z8788bd13 File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi

2023-05-07T13:21:26.532Z8788bd13 self.load_wsgi()

2023-05-07T13:21:26.532Z8788bd13 File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 134, in init_process

2023-05-07T13:21:26.532Z8788bd13 worker.init_process()

2023-05-07T13:21:26.532Z8788bd13 File "/usr/local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker

2023-05-07T13:21:26.532Z8788bd13Traceback (most recent call last):

2023-05-07T13:21:26.532Z8788bd13[2023-05-07 13:21:26 +0000] [7] [ERROR] Exception in worker process

2023-05-07T13:21:26.639Z8788bd13[2023-05-07 13:21:26 +0000] [1] [INFO] Reason: Worker failed to boot.

2023-05-07T13:21:26.639Z8788bd13[2023-05-07 13:21:26 +0000] [1] [INFO] Shutting down: Master

2023-05-07T13:33:10.244Zaa33b43a[2023-05-07 13:33:10 +0000] [1] [INFO] Starting gunicorn 20.1.0

2023-05-07T13:33:10.246Zaa33b43a[2023-05-07 13:33:10 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1)

2023-05-07T13:33:10.246Zaa33b43a[2023-05-07 13:33:10 +0000] [1] [INFO] Using worker: sync

2023-05-07T13:33:10.251Zaa33b43a[2023-05-07 13:33:10 +0000] [7] [INFO] Booting worker with pid: 7

2023-05-07T13:33:10.254Zaa33b43a[2023-05-07 13:33:10 +0000] [7] [ERROR] Exception in worker process

2023-05-07T13:33:10.254Zaa33b43aTraceback (most recent call last):

2023-05-07T13:33:10.254Zaa33b43a File "/usr/local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker

2023-05-07T13:33:10.254Zaa33b43a worker.init_process()

2023-05-07T13:33:10.254Zaa33b43a File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 134, in init_process

2023-05-07T13:33:10.254Zaa33b43a self.load_wsgi()

2023-05-07T13:33:10.254Zaa33b43a File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi

2023-05-07T13:33:10.254Zaa33b43a self.wsgi = self.app.wsgi()

2023-05-07T13:33:10.254Zaa33b43a File "/usr/local/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi

2023-05-07T13:33:10.254Zaa33b43a self.callable = self.load()

2023-05-07T13:33:10.254Zaa33b43a File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load

2023-05-07T13:33:10.254Zaa33b43a return self.load_wsgiapp()

2023-05-07T13:33:10.254Zaa33b43a File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp

2023-05-07T13:33:10.254Zaa33b43a return util.import_app(self.app_uri)

2023-05-07T13:33:10.254Zaa33b43a File "/usr/local/lib/python3.9/site-packages/gunicorn/util.py", line 359, in import_app

2023-05-07T13:33:10.254Zaa33b43a mod = importlib.import_module(module)

2023-05-07T13:33:10.254Zaa33b43a File "/usr/local/lib/python3.9/importlib/init.py", line 127, in import_module

2023-05-07T13:33:10.254Zaa33b43a return _bootstrap._gcd_import(name[level:], package, level)

2023-05-07T13:33:10.254Zaa33b43a File "", line 1030, in _gcd_import

2023-05-07T13:33:10.254Zaa33b43a File "", line 1007, in _find_and_load

2023-05-07T13:33:10.254Zaa33b43a File "", line 984, in _find_and_load_unlocked

2023-05-07T13:33:10.254Zaa33b43aModuleNotFoundError: No module named 'app'

2023-05-07T13:33:10.255Zaa33b43a[2023-05-07 13:33:10 +0000] [7] [INFO] Worker exiting (pid: 7)

2023-05-07T13:33:10.427Zaa33b43a[2023-05-07 13:33:10 +0000] [1] [INFO] Shutting down: Master

2023-05-07T13:33:10.431Zaa33b43a[2023-05-07 13:33:10 +0000] [1] [INFO] Reason: Worker failed to boot.

Teslajke
  • 99
  • 4

2 Answers2

0

Found the issue. Corrected work directory id Dockerfile:

FROM python:3.9-slim

WORKDIR /main

COPY requirements.txt requirements.txt RUN pip install --upgrade pip RUN pip install --no-cache-dir -r requirements.txt

COPY . .

EXPOSE 8080

CMD ["gunicorn", "-b", "0.0.0.0:8080", "main:app"]

Teslajke
  • 99
  • 4
-1

I think there is an other application running on the server or else you can use other port .

  • They suggest this port in the documentation https://www.back4app.com/docs-containers/run-a-flask-container-app – Teslajke May 07 '23 at 12:52