How to stop gunicorn from shutting down automatically in Google Cloud?

Viewed 742

My app has a tensorflow model to load and it takes around 20 secs to load it, but after deploying it in app engine it automatically shutdown after 7 minutes into starting the app and restart again. While this restarting the app wont work. How to avoid this? And what is this "Error while closing socket"

logs:

A 2021-03-23T06:10:28Z [2021-03-23 06:10:28 +0000] [8] [INFO] Application startup complete.
 
A 2021-03-23T06:17:26Z [2021-03-23 06:17:26 +0000] [1] [INFO] Handling signal: term
 
A 2021-03-23T06:17:26Z [2021-03-23 06:17:26 +0000] [8] [INFO] Shutting down
 
A 2021-03-23T06:17:26Z [2021-03-23 06:17:26 +0000] [8] [INFO] Error while closing socket [Errno 9] Bad file descriptor
 
A 2021-03-23T06:17:26Z [2021-03-23 06:17:26 +0000] [8] [INFO] Waiting for application shutdown.
 
A 2021-03-23T06:17:26Z [2021-03-23 06:17:26 +0000] [8] [INFO] Application shutdown complete.
 
A 2021-03-23T06:17:26Z [2021-03-23 06:17:26 +0000] [8] [INFO] Finished server process [8]
 
A 2021-03-23T06:17:26Z [2021-03-23 06:17:26 +0000] [8] [INFO] Worker exiting (pid: 8)
 
A 2021-03-23T06:17:27Z [2021-03-23 06:17:27 +0000] [1] [INFO] Shutting down: Master
 
A 2021-03-23T06:20:07Z [2021-03-23 06:20:07 +0000] [1] [INFO] Starting gunicorn 20.0.4

App.yaml:

runtime: python
env: flex

runtime_config:
    python_version: 3

automatic_scaling:
  min_num_instances: 1
  max_num_instances: 1
  cpu_utilization:
    target_utilization: 1
readiness_check:
  app_start_timeout_sec: 1800
liveness_check:
  path: "/liveness_check"
  check_interval_sec: 30
resources:
    cpu: 1
    memory_gb: 6
    disk_size_gb: 15
                      
entrypoint: gunicorn -k uvicorn.workers.UvicornWorker app.main:app --timeout 1000
0 Answers
Related