I have a Flask app server with celery worker for task queue using Redis database.
This is the Render.yaml file for the service
services:
- type: worker
name: celery-worker
region: oregon
runtime: python
buildCommand: "pip install -r requirements.txt"
startCommand: "celery -A celeryconfig.celery_app worker -Q default -l info --pool=solo --concurrency=8"
autoDeploy: false
envVars:
- key: REDIS_URL
fromService:
name: celery-redis
type: redis
property: connectionString
- type: web
name: app
region: oregon
runtime: python
buildCommand: "pip install -r requirements.txt"
startCommand: "gunicorn app:app -t 60 --keep-alive 60"
autoDeploy: false
envVars:
- key: REDIS_URL
fromService:
name: celery-redis
type: redis
property: connectionString
- type: web
name: flower
region: oregon
plan: free
runtime: python
buildCommand: "pip install -r requirements.txt"
startCommand: "celery -A celeryconfig.celery_app flower"
autoDeploy: false
envVars:
- key: REDIS_URL
fromService:
type: redis
name: celery-redis
property: connectionString
- type: redis
name: celery-redis
region: oregon
plan: starter # we choose a plan with persistence to ensure tasks are not lost upon restart
maxmemoryPolicy: noeviction # recommended policy for queues
ipAllowList: [] # only allow internal connections
and this is a /submit endpoint in the Flask server
@app.route('/submit', methods=['POST'])
def submit():
json_data = request.get_json()
task = generate_word_groups_from_input.apply_async(args=[json_data])
return jsonify({"task_id": task.id}), 202
From the client side, when I access the /submit endpoint by submitting some data as json. I am getting the following error in the Render log
[2024-08-15 03:31:59 +0000] [90] [CRITICAL] WORKER TIMEOUT (pid:109)
[2024-08-15 03:31:59 +0000] [109] [INFO] Worker exiting (pid: 109)
[2024-08-15 03:32:00 +0000] [90] [WARNING] Worker with pid 109 was terminated due to signal 9
[2024-08-15 03:32:00 +0000] [110] [INFO] Booting worker with pid: 110
==> Detected service running on port 10000
==> Docs on specifying a port: https://render.com/docs/web-services#port-binding
[2024-08-15 03:47:28 +0000] [90] [INFO] Handling signal: term
[2024-08-15 03:47:28 +0000] [110] [INFO] Worker exiting (pid: 110)
[2024-08-15 03:47:31 +0000] [90] [INFO] Shutting down: Master
I also get this error on console of my browser
ailed to load resource: the server responded with a status of 502 ()Understand this error
index.js:265 Error: Error: Server responded with an error
at index.js:250:19
(anonymous) @ index.js:265Understand this error
index.js:269 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'style')
at index.js:269:26
I never faced any problem in the local deployment.
I read the previous posts in this regard and changed the timeout for gunicorn
startCommand: "gunicorn app:app -t 60 --keep-alive 60"
But still the problem has not been solved.
Can someone please help.