-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Description
This works fine on my local machine but it's not working on my EC2. I always see this error:
[2025-03-18 08:15:33 +0000] [7] [INFO] Worker exiting (pid: 7)
[2025-03-18 08:15:33 +0000] [1] [ERROR] Worker (pid:7) exited with code 3
[2025-03-18 08:15:33 +0000] [1] [ERROR] Shutting down: Master
[2025-03-18 08:15:33 +0000] [1] [ERROR] Reason: Worker failed to boot.
[2025-03-18 08:16:35 +0000] [1] [INFO] Starting gunicorn 23.0.0
[2025-03-18 08:16:35 +0000] [1] [INFO] Listening at: http://0.0.0.0:5000 (1)
[2025-03-18 08:16:35 +0000] [1] [INFO] Using worker: sync
[2025-03-18 08:16:35 +0000] [7] [INFO] Booting worker with pid: 7
[2025-03-18 08:16:36 +0000] [7] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 608, in spawn_worker
worker.init_process()
File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 135, in init_process
self.load_wsgi()
File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 147, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python3.9/site-packages/gunicorn/app/base.py", line 66, in wsgi
self.callable = self.load()
File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 57, in load
return self.load_wsgiapp()
File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 47, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python3.9/site-packages/gunicorn/util.py", line 370, in import_app
mod = importlib.import_module(module)
File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/app/app/__init__.py", line 8, in <module>
from app.routes import user_bp, patient_bp, mail
File "/app/app/routes.py", line 4, in <module>
from app.utils import send_push_notification, validate_date, validate, hash_password, check_password, generate_confirmation_token, confirm_token, validate_email
File "/app/app/utils.py", line 6, in <module>
from exponent_server_sdk import (
ModuleNotFoundError: No module named 'exponent_server_sdk'
Here are my files for your references:
Env:
python: 3.9
flask : 3.1
Dockerfile
FROM python:3.9-slim
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
WORKDIR /app
RUN apt-get update && rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
COPY . .
EXPOSE 5000
CMD ["gunicorn", "-b", "0.0.0.0:5000", "app:app"]
requirement.txt
Flask
Flask-SQLAlchemy
Flask-Migrate
Flask-Mail
gunicorn
PyMySQL
bcrypt
itsdangerous
cryptography
python-dotenv
flask-cors
flask_jwt_extended
email_validator
Flask-APScheduler
requests
exponent-server-sdk (I also tried: exponent_server_sdk and exponent-server-sdk==2.1.0 but with no luck)
Here is how I call the API:
I worked locally
def send_push_notification(push_token, title, body):
client = PushClient()
response = client.publish(PushMessage(to=push_token, title=title, body=body, sound="default", channel_id="default"))
response.validate_response()
return 200, {"status": "ok"}
I barely find solution online, please provide some more insights.
If you need anything else please let me know.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels