[Python] ‘Fail due to unhealthy allocation' deploying django site using fly.io

Discussão em 'Python' iniciado por Stack, Junho 2, 2025.

  1. Stack

    Stack Membro Participativo

    I am super new to deployment and django and I’m trying to deploy a simple django site without database with fly.io. I’ve been getting errors for 4 days and would really appreciate it if anyone can help! The error is below

    ==> Creating release
    --> release v3 created

    --> You can detach the terminal anytime without stopping the deployment
    ==> Monitoring deployment
    Logs: https://fly.io/apps/chaplinhuang/monitoring

    1 desired, 1 placed, 0 healthy, 1 unhealthy [restarts: 2] [health checks: 1 total]
    Failed Instances

    Failure #1

    Instance
    ID PROCESS VERSION REGION DESIRED STATUS HEALTH CHECKS RESTARTS CREATED
    00d71cce app 3 ord run pending 1 total 2 1m0s ago

    Recent Events
    TIMESTAMP TYPE MESSAGE
    2022-12-26T02:05:54Z Received Task received by client
    2022-12-26T02:05:54Z Task Setup Building Task Directory
    2022-12-26T02:06:25Z Started Task started by client
    2022-12-26T02:06:27Z Terminated Exit Code: 3
    2022-12-26T02:06:27Z Restarting Task restarting in 1.042869453s
    2022-12-26T02:06:44Z Started Task started by client
    2022-12-26T02:06:46Z Terminated Exit Code: 3
    2022-12-26T02:06:46Z Restarting Task restarting in 1.11932696s

    2022-12-26T02:07:03Z [info][2022-12-26 02:07:03 +0000] [525] [INFO] Booting worker with pid: 525
    2022-12-26T02:07:03Z [info][2022-12-26 02:07:03 +0000] [525] [ERROR] Exception in worker process
    2022-12-26T02:07:03Z [info]Traceback (most recent call last):
    2022-12-26T02:07:03Z [info] File "/usr/local/lib/python3.10/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
    2022-12-26T02:07:03Z [info] worker.init_process()
    2022-12-26T02:07:03Z [info] File "/usr/local/lib/python3.10/site-packages/gunicorn/workers/base.py", line 134, in init_process
    2022-12-26T02:07:03Z [info] self.load_wsgi()
    2022-12-26T02:07:03Z [info] File "/usr/local/lib/python3.10/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
    2022-12-26T02:07:03Z [info] self.wsgi = self.app.wsgi()
    2022-12-26T02:07:03Z [info] File "/usr/local/lib/python3.10/site-packages/gunicorn/app/base.py", line 67, in wsgi
    2022-12-26T02:07:03Z [info] self.callable = self.load()
    2022-12-26T02:07:03Z [info] File "/usr/local/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
    2022-12-26T02:07:03Z [info] return self.load_wsgiapp()
    2022-12-26T02:07:03Z [info] File "/usr/local/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
    2022-12-26T02:07:03Z [info] return util.import_app(self.app_uri)
    2022-12-26T02:07:03Z [info] File "/usr/local/lib/python3.10/site-packages/gunicorn/util.py", line 359, in import_app
    2022-12-26T02:07:03Z [info] mod = importlib.import_module(module)
    2022-12-26T02:07:03Z [info] File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
    2022-12-26T02:07:03Z [info] return _bootstrap._gcd_import(name[level:], package, level)
    2022-12-26T02:07:03Z [info] File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
    2022-12-26T02:07:03Z [info] File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
    2022-12-26T02:07:03Z [info] File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
    2022-12-26T02:07:03Z [info] File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
    2022-12-26T02:07:03Z [info] File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
    2022-12-26T02:07:03Z [info] File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
    2022-12-26T02:07:03Z [info] File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
    2022-12-26T02:07:03Z [info]ModuleNotFoundError: No module named 'demo'
    2022-12-26T02:07:04Z [info][2022-12-26 02:07:04 +0000] [520] [INFO] Shutting down: Master
    2022-12-26T02:07:04Z [info][2022-12-26 02:07:04 +0000] [520] [INFO] Reason: Worker failed to boot.
    2022-12-26T02:07:04Z [info]Starting clean up.
    --> v3 failed - Failed due to unhealthy allocations - no stable job version to auto revert to and deploying as v4

    --> Troubleshooting guide at https://fly.io/docs/getting-started/troubleshooting/
    Error abort


    My current fly.toml


    # fly.toml file generated for chaplinhuang on 2022-12-24T18:27:36+08:00

    app = "chaplinhuang"
    kill_signal = "SIGINT"
    kill_timeout = 5
    processes = []

    [env]
    PORT = "8080"

    [experimental]
    allowed_public_ports = []
    auto_rollback = true

    [[services]]
    http_checks = []
    internal_port = 8080
    processes = ["app"]
    protocol = "tcp"
    script_checks = []
    [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

    [[services.ports]]
    force_https = true
    handlers = ["http"]
    port = 80

    [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

    [[services.tcp_checks]]
    grace_period = "30s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

    [[statics]]
    guest_path = "/app/public"
    url_prefix = "/static/"


    My current Dockerfile

    ARG PYTHON_VERSION=3.10-slim-buster

    FROM python:${PYTHON_VERSION}

    ENV PYTHONDONTWRITEBYTECODE 1
    ENV PYTHONUNBUFFERED 1

    RUN mkdir -p /code

    WORKDIR /code

    COPY requirements.txt /tmp/requirements.txt

    RUN set -ex && \
    pip install --upgrade pip && \
    pip install -r /tmp/requirements.txt && \
    rm -rf /root/.cache/

    COPY . /code/

    RUN python manage.py collectstatic --noinput

    EXPOSE 8000

    # replace demo.wsgi with <project_name>.wsgi
    CMD ["gunicorn", "--bind", ":8000", "--workers", "2", "demo.wsgi"]



    I have tried to change the port to 8080, but cannot change ip address to 0.0.0.0, what should I do? Any input is appreciated!

    Continue reading...

Compartilhe esta Página