gunicorn killing workers repeatedly with no traffic - python-3.x

I have a Flask app running on top of gunicorn which works fine on centos8 and rhel8. I'm trying to bring the app up on an rhel8 derivative which is hardened for FIPS/military compliance. This new os constantly sees workers timing out with no REST traffic offered.
The keepalive files are not having their timestamps updated by the worker threads which leads the arbiter to kill them off. I've added enough debug code to know that much.
I've studied the code and see that gunicorn uses a notify mechanism which relies on updating the permissions on temporary files. I've been looking around for these files but can't seem to find them. I've looked in /tmp (which I believe to be the default) and even set --worker-tmp-dir /tmp/gunicorn with no luck. Both are empty.
Any advice on how to proceed here will be appreciated.
[root#host-172-23-14-219 ~]# ls -ltr /tmp/gunicorn/
total 0
[root#host-172-23-14-219 ~]# ls -latr /tmp/gunicorn/
total 0
These are the messages I see in the debug output. The repeat every 30 seconds which is the default value for timeout. If I change the timeout, the time before being killed increases.
[2021-01-15 16:33:21 +0300] [9120] [CRITICAL] WORKER TIMEOUT (pid:14483)
[2021-01-15 16:33:21 +0300] [9120] [CRITICAL] WORKER TIMEOUT (pid:14485)
[2021-01-15 16:33:21 +0300] [9120] [CRITICAL] WORKER TIMEOUT (pid:14488)
[2021-01-15 16:33:21 +0300] [14483] [INFO] Worker exiting (pid: 14483)
[2021-01-15 16:33:21 +0300] [14485] [INFO] Worker exiting (pid: 14485)
[2021-01-15 16:33:21 +0300] [14488] [INFO] Worker exiting (pid: 14488)
[2021-01-15 16:33:21 +0300] [14782] [INFO] Booting worker with pid: 14782
[2021-01-15 16:33:21 +0300] [9120] [DEBUG] 1 workers
[2021-01-15 16:33:21 +0300] [14783] [INFO] Booting worker with pid: 14783
[2021-01-15 16:33:21 +0300] [14785] [INFO] Booting worker with pid: 14785
[2021-01-15 16:33:21 +0300] [9120] [DEBUG] 3 workers
Complete trace running gunicorn from the command line.
[root#dbaas1 restapi]# /usr/bin/python3 /usr/local/bin/gunicorn --log-level debug --log-syslog --workers 3 --bind 127.0.0.1:5000 -m 007 wsgi:app
[2021-01-18 22:11:23 +0300] [2942060] [DEBUG] Current configuration:
config: None
bind: ['127.0.0.1:5000']
backlog: 2048
workers: 3
worker_class: sync
threads: 1
worker_connections: 1000
max_requests: 0
max_requests_jitter: 0
timeout: 30
graceful_timeout: 30
keepalive: 2
limit_request_line: 4094
limit_request_fields: 100
limit_request_field_size: 8190
reload: False
reload_engine: auto
reload_extra_files: []
spew: False
check_config: False
preload_app: False
sendfile: None
reuse_port: False
chdir: /opt/rbbn/dbaas/src/serviceDiscovery/restapi
daemon: False
raw_env: []
pidfile: None
worker_tmp_dir: None
user: 0
group: 0
umask: 7
initgroups: False
tmp_upload_dir: None
secure_scheme_headers: {'X-FORWARDED-PROTOCOL': 'ssl', 'X-FORWARDED-PROTO': 'https', 'X-FORWARDED-SSL': 'on'}
forwarded_allow_ips: ['127.0.0.1']
accesslog: None
disable_redirect_access_to_syslog: False
access_log_format: %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"
errorlog: -
loglevel: debug
capture_output: False
logger_class: gunicorn.glogging.Logger
logconfig: None
logconfig_dict: {}
syslog_addr: udp://localhost:514
syslog: True
syslog_prefix: None
syslog_facility: user
enable_stdio_inheritance: False
statsd_host: None
dogstatsd_tags:
statsd_prefix:
proc_name: None
default_proc_name: wsgi:app
pythonpath: None
paste: None
on_starting: <function OnStarting.on_starting at 0x7f13b046be18>
on_reload: <function OnReload.on_reload at 0x7f13b046bf28>
when_ready: <function WhenReady.when_ready at 0x7f13b04860d0>
pre_fork: <function Prefork.pre_fork at 0x7f13b04861e0>
post_fork: <function Postfork.post_fork at 0x7f13b04862f0>
post_worker_init: <function PostWorkerInit.post_worker_init at 0x7f13b0486400>
worker_int: <function WorkerInt.worker_int at 0x7f13b0486510>
worker_abort: <function WorkerAbort.worker_abort at 0x7f13b0486620>
pre_exec: <function PreExec.pre_exec at 0x7f13b0486730>
pre_request: <function PreRequest.pre_request at 0x7f13b0486840>
post_request: <function PostRequest.post_request at 0x7f13b04868c8>
child_exit: <function ChildExit.child_exit at 0x7f13b04869d8>
worker_exit: <function WorkerExit.worker_exit at 0x7f13b0486ae8>
nworkers_changed: <function NumWorkersChanged.nworkers_changed at 0x7f13b0486bf8>
on_exit: <function OnExit.on_exit at 0x7f13b0486d08>
proxy_protocol: False
proxy_allow_ips: ['127.0.0.1']
keyfile: None
certfile: None
ssl_version: 2
cert_reqs: 0
ca_certs: None
suppress_ragged_eofs: True
do_handshake_on_connect: False
ciphers: None
raw_paste_global_conf: []
strip_header_spaces: False
[2021-01-18 22:11:23 +0300] [2942060] [INFO] Starting gunicorn 20.0.4
[2021-01-18 22:11:23 +0300] [2942060] [DEBUG] Arbiter booted
[2021-01-18 22:11:23 +0300] [2942060] [INFO] Listening at: http://127.0.0.1:5000 (2942060)
[2021-01-18 22:11:23 +0300] [2942060] [INFO] Using worker: sync
[2021-01-18 22:11:23 +0300] [2942066] [INFO] Booting worker with pid: 2942066
[2021-01-18 22:11:23 +0300] [2942068] [INFO] Booting worker with pid: 2942068
[2021-01-18 22:11:23 +0300] [2942069] [INFO] Booting worker with pid: 2942069
[2021-01-18 22:11:23 +0300] [2942060] [DEBUG] 3 workers
[2021-01-18 22:11:53 +0300] [2942060] [CRITICAL] WORKER TIMEOUT (pid:2942066)
[2021-01-18 22:11:53 +0300] [2942060] [CRITICAL] WORKER TIMEOUT (pid:2942068)
[2021-01-18 22:11:53 +0300] [2942060] [CRITICAL] WORKER TIMEOUT (pid:2942069)
[2021-01-18 22:11:53 +0300] [2942066] [INFO] Worker exiting (pid: 2942066)
[2021-01-18 22:11:53 +0300] [2942068] [INFO] Worker exiting (pid: 2942068)
[2021-01-18 22:11:53 +0300] [2942069] [INFO] Worker exiting (pid: 2942069)
[2021-01-18 22:11:53 +0300] [2942357] [INFO] Booting worker with pid: 2942357
[2021-01-18 22:11:53 +0300] [2942060] [DEBUG] 1 workers
[2021-01-18 22:11:53 +0300] [2942359] [INFO] Booting worker with pid: 2942359
[2021-01-18 22:11:53 +0300] [2942360] [INFO] Booting worker with pid: 2942360
[2021-01-18 22:11:53 +0300] [2942060] [DEBUG] 3 workers

Running into a similar problem - everything works fine on Ubuntu 18.04, but fails consistently with similar errors / logging on Ubuntu 22.04.
Try increasing timeout higher than 30 in gunicorn config / settings.
Changing the timeout to 90 was sufficient for me to get things working again - my best guess is that the initial load-in of the Flask app takes longer on some machines and so it's hitting this limit.

Related

Flask application unable to start on Azure, connection in use

I tried to deploy very simple Flask application:
import flask
app = flask.Flask(__name__)
#app.route('/', methods=['GET'])
def home():
return '<h1>Hello!</h1></p>'
app.run()
I followed some official tutorials, created App Service in Azure Portal, deployed app using Local Git solution. Application is deployed, but when I try to browse it, I get:
:( Application Error. If you are the application administrator, you can access the diagnostic resources.
My logs:
2022-09-22T14:24:17.032341362Z
2022-09-22T14:24:17.032431764Z _____
2022-09-22T14:24:17.032440964Z / _ \ __________ _________ ____
2022-09-22T14:24:17.032445564Z / /_\ \___ / | \_ __ \_/ __ \
2022-09-22T14:24:17.032449964Z / | \/ /| | /| | \/\ ___/
2022-09-22T14:24:17.032454364Z \____|__ /_____ \____/ |__| \___ >
2022-09-22T14:24:17.032458965Z \/ \/ \/
2022-09-22T14:24:17.032463265Z
2022-09-22T14:24:17.032467265Z A P P S E R V I C E O N L I N U X
2022-09-22T14:24:17.032471165Z
2022-09-22T14:24:17.032474965Z Documentation: http://aka.ms/webapp-linux
2022-09-22T14:24:17.032489065Z Python 3.9.7
2022-09-22T14:24:17.032493765Z Note: Any data outside '/home' is not persisted
2022-09-22T14:24:17.180055832Z Starting OpenBSD Secure Shell server: sshd.
2022-09-22T14:24:17.215008000Z App Command Line not configured, will attempt auto-detect
2022-09-22T14:24:17.433349825Z Starting periodic command scheduler: cron.
2022-09-22T14:24:17.442192344Z Launching oryx with: create-script -appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv -defaultApp /opt/defaultsite
2022-09-22T14:24:17.556237878Z Found build manifest file at '/home/site/wwwroot/oryx-manifest.toml'. Deserializing it...
2022-09-22T14:24:17.562671538Z Output is compressed. Extracting it...
2022-09-22T14:24:17.564241977Z Build Operation ID: |OgP/jQgIHgU=.1da790b7_
2022-09-22T14:24:17.564259877Z Oryx Version: 0.2.20220825.1, Commit: 24032445dbf7bf6ef068688f1b123a7144453b7f, ReleaseTagName: 20220825.1
2022-09-22T14:24:17.565391205Z Extracting '/home/site/wwwroot/output.tar.gz' to directory '/tmp/8da9ca604221f20'...
2022-09-22T14:24:18.725265722Z App path is set to '/tmp/8da9ca604221f20'
2022-09-22T14:24:19.018530608Z Detected an app based on Flask
2022-09-22T14:24:19.405035911Z Generating `gunicorn` command for 'index:app'
2022-09-22T14:24:19.456995902Z Writing output script to '/opt/startup/startup.sh'
2022-09-22T14:24:19.689506779Z Using packages from virtual environment antenv located at /tmp/8da9ca604221f20/antenv.
2022-09-22T14:24:19.690332099Z Updated PYTHONPATH to ':/opt/startup/app_logs:/opt/startup/code_profiler:/tmp/8da9ca604221f20/antenv/lib/python3.9/site-packages'
2022-09-22T14:24:20.556171311Z [2022-09-22 14:24:20 +0000] [77] [INFO] Starting gunicorn 20.1.0
2022-09-22T14:24:20.595370385Z [2022-09-22 14:24:20 +0000] [77] [INFO] Listening at: http://0.0.0.0:8000 (77)
2022-09-22T14:24:20.601700442Z [2022-09-22 14:24:20 +0000] [77] [INFO] Using worker: sync
2022-09-22T14:24:20.610324257Z [2022-09-22 14:24:20 +0000] [80] [INFO] Booting worker with pid: 80
2022-09-22T14:24:21.265168226Z * Serving Flask app 'index'
2022-09-22T14:24:21.266054348Z * Debug mode: on
2022-09-22T14:24:21.300157595Z [31m[1mWARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.[0m
2022-09-22T14:24:21.300272498Z * Running on http://127.0.0.1:5000
2022-09-22T14:24:21.301268023Z [33mPress CTRL+C to quit[0m
2022-09-22T14:24:21.308547204Z * Restarting with stat
2022-09-22T14:24:21.760007120Z [2022-09-22 14:24:21 +0000] [81] [INFO] Starting gunicorn 20.1.0
2022-09-22T14:24:21.772788238Z [2022-09-22 14:24:21 +0000] [81] [ERROR] Connection in use: ('0.0.0.0', 8000)
2022-09-22T14:24:21.773676260Z [2022-09-22 14:24:21 +0000] [81] [ERROR] Retrying in 1 second.
2022-09-22T14:24:22.779581652Z [2022-09-22 14:24:22 +0000] [81] [ERROR] Connection in use: ('0.0.0.0', 8000)
2022-09-22T14:24:22.780698179Z [2022-09-22 14:24:22 +0000] [81] [ERROR] Retrying in 1 second.
2022-09-22T14:24:23.781856453Z [2022-09-22 14:24:23 +0000] [81] [ERROR] Connection in use: ('0.0.0.0', 8000)
2022-09-22T14:24:23.783124685Z [2022-09-22 14:24:23 +0000] [81] [ERROR] Retrying in 1 second.
2022-09-22T14:24:24.787329534Z [2022-09-22 14:24:24 +0000] [81] [ERROR] Connection in use: ('0.0.0.0', 8000)
2022-09-22T14:24:24.788615966Z [2022-09-22 14:24:24 +0000] [81] [ERROR] Retrying in 1 second.
2022-09-22T14:24:25.792686075Z [2022-09-22 14:24:25 +0000] [81] [ERROR] Connection in use: ('0.0.0.0', 8000)
2022-09-22T14:24:25.794038102Z [2022-09-22 14:24:25 +0000] [81] [ERROR] Retrying in 1 second.
2022-09-22T14:24:26.795751866Z [2022-09-22 14:24:26 +0000] [81] [ERROR] Can't connect to ('0.0.0.0', 8000)
2022-09-22T14:24:26.839176431Z [2022-09-22 14:24:26 +0000] [80] [INFO] Worker exiting (pid: 80)
2022-09-22T14:24:26.928820618Z [2022-09-22 14:24:26 +0000] [84] [INFO] Booting worker with pid: 84
It happens all the time, starting, problem with port, restarting, again and again. As I said, I just followed tutorials, didn't change any port or IP address...
I found a solution. My code was development version - in logs was a warning:
WARNING: This is a development server. Do not use it in a production
deployment. Use a production WSGI server instead
I changed code as was answered in Flask at first run: Do not use the development server in a production environment :
import flask
app = flask.Flask(__name__)
#app.route('/', methods=['GET'])
def home():
return '<h1>Hello!</h1></p>'
# debug app:
# app.run()
if __name__ == "__main__":
from waitress import serve
serve(app, host="0.0.0.0", port=8080)
Now application is deployed to Azure and working properly.

FastAPI app deployed without any errors on gcloud, but the target link gives 500 server error

I deployed a FastAPI project on google app engine.
Here's my main.py file:
from fastapi import FastAPI;
from fastapi.staticfiles import StaticFiles
from app.routes.routes import router as appRoutes;
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI()
origins = [
"http://localhost",
"http://localhost:8000",
]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
#app.get('/')
def root():
return "Welcome to the fastapi backend"
app.include_router(appRoutes,prefix='/api')
app.yaml:
runtime: python37
entrypoint: gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app
and requirements.txt:
fastapi
numpy
uvicorn
scikit-learn
pandas
nltk
gunicorn
pydantic
Upon running gcloud app deploy, the app is deployed without any errors:
File upload done. Updating service [default]...done. Setting
traffic split for service [default]...done. Deployed service
[default] to [.....
when I run gcloud app browse, it gives me:
Did not detect your browser. Go to this link to view your app:
and upon visiting the link I get:
Error: Server Error The server encountered an error and could not
complete your request. Please try again in 30 seconds.
I am not really that much into deployment in general so I might be missing out on something.
What exactly is going wrong here? I can't see any error messages...
Edit:
On checking gcloud app logs tail -s default
2022-09-08 05:57:32 default[20220908t054903] [2022-09-08 05:57:32
+0000] [10] [INFO] Starting gunicorn 20.1.0 2022-09-08 05:57:32 default[20220908t054903] [2022-09-08 05:57:32 +0000] [10] [INFO] Listening at: http://0.0.0.0:8081 (10) 2022-09-08 05:57:32 default[20220908t054903] [2022-09-08 05:57:32 +0000] [10] [INFO] Using worker: uvicorn.workers.UvicornWorker 2022-09-08 05:57:32 default[20220908t054903] [2022-09-08 05:57:32 +0000] [16] [INFO] Booting worker with pid: 16 2022-09-08 05:57:32 default[20220908t054903] [2022-09-08 05:57:32 +0000] [19] [INFO] Booting worker with pid: 19 2022-09-08 05:57:32 default[20220908t054903] [2022-09-08 05:57:32 +0000] [20] [INFO] Booting worker with pid: 20 2022-09-08 05:57:32 default[20220908t054903] [2022-09-08 05:57:32 +0000] [21] [INFO] Booting worker with pid: 21 2022-09-08 05:57:34 default[20220908t054903] [2022-09-08 05:57:34 +0000] [10] [INFO] Starting gunicorn 20.1.0 2022-09-08 05:57:34 default[20220908t054903] [2022-09-08 05:57:34 +0000] [10] [INFO] Listening at: http://0.0.0.0:8081 (10) 2022-09-08 05:57:34 default[20220908t054903] [2022-09-08 05:57:34 +0000] [10] [INFO] Using worker: uvicorn.workers.UvicornWorker 2022-09-08 05:57:34 default[20220908t054903] [2022-09-08 05:57:34 +0000] [16] [INFO] Booting worker with pid: 16 2022-09-08 05:57:34 default[20220908t054903] [2022-09-08 05:57:34 +0000] [19] [INFO] Booting worker with pid: 19 2022-09-08 05:57:34 default[20220908t054903] [2022-09-08 05:57:34 +0000] [20] [INFO] Booting worker with pid: 20 2022-09-08 05:57:34 default[20220908t054903] [2022-09-08 05:57:34 +0000] [21] [INFO] Booting worker with pid: 21 2022-09-08 05:57:36 default[20220908t054903] [2022-09-08 05:57:36 +0000] [10] [INFO] Handling signal: term 2022-09-08 05:57:36 default[20220908t054903] [2022-09-08 05:57:36 +0000] [10] [WARNING] Worker with pid 21 was terminated due to signal 15 2022-09-08 05:57:36 default[20220908t054903] [2022-09-08 05:57:36 +0000] [10] [WARNING] Worker with pid 19 was terminated due to signal 15 2022-09-08 05:57:36 default[20220908t054903] [2022-09-08 05:57:36 +0000] [10] [WARNING] Worker with pid 16 was terminated due to signal 15 2022-09-08 05:57:36 default[20220908t054903] [2022-09-08 05:57:36 +0000] [10] [WARNING] Worker with pid 20 was terminated due to signal 15 2022-09-08 05:57:36 default[20220908t054903] [2022-09-08 05:57:36 +0000] [10] [INFO] Shutting down: Master 2022-09-08 05:57:37 default[20220908t054903] [2022-09-08 05:57:37 +0000] [10] [INFO] Handling signal: term 2022-09-08 05:57:37 default[20220908t054903] [2022-09-08 05:57:37
+0000] [10] [WARNING] Worker with pid 21 was terminated due to signal 15 2022-09-08 05:57:37 default[20220908t054903] [2022-09-08 05:57:37
+0000] [10] [WARNING] Worker with pid 19 was terminated due to signal 15 2022-09-08 05:57:37 default[20220908t054903] [2022-09-08 05:57:37
+0000] [10] [WARNING] Worker with pid 20 was terminated due to signal 15 2022-09-08 05:57:37 default[20220908t054903] [2022-09-08 05:57:37
+0000] [10] [WARNING] Worker with pid 16 was terminated due to signal 15 2022-09-08 05:57:37 default[20220908t054903] [2022-09-08 05:57:37
+0000] [10] [INFO] Shutting down: Master 2022-09-08 05:57:38 default[20220908t055413] [2022-09-08 05:57:38 +0000] [11] [INFO] Starting gunicorn 20.1.0 2022-09-08 05:57:38 default[20220908t055413] [2022-09-08 05:57:38 +0000] [11] [INFO] Listening at: http://0.0.0.0:8081 (11) 2022-09-08 05:57:38 default[20220908t055413] [2022-09-08 05:57:38 +0000] [11] [INFO] Using worker: uvicorn.workers.UvicornWorker 2022-09-08 05:57:38 default[20220908t055413] [2022-09-08 05:57:38 +0000] [16] [INFO] Booting worker with pid: 16 2022-09-08 05:57:38 default[20220908t055413] [2022-09-08 05:57:38 +0000] [19] [INFO] Booting worker with pid: 19 2022-09-08 05:57:38 default[20220908t055413] [2022-09-08 05:57:38 +0000] [20] [INFO] Booting worker with pid: 20 2022-09-08 05:57:38 default[20220908t055413] [2022-09-08 05:57:38 +0000] [21] [INFO] Booting worker with pid: 21 2022-09-08 05:57:41 default[20220908t055413] [2022-09-08 05:57:41 +0000] [11] [INFO] Handling signal: term 2022-09-08 05:57:41 default[20220908t055413] [2022-09-08 05:57:41 +0000] [11] [WARNING] Worker with pid 16 was terminated due to signal 15 2022-09-08 05:57:41 default[20220908t055413] [2022-09-08 05:57:41 +0000] [11] [WARNING] Worker with pid 19 was terminated due to signal 15 2022-09-08 05:57:41 default[20220908t055413] [2022-09-08 05:57:41 +0000] [11] [WARNING] Worker with pid 20 was terminated due to signal 15 2022-09-08 05:57:41 default[20220908t055413] [2022-09-08 05:57:41 +0000] [11] [WARNING] Worker with pid 21 was terminated due to signal 15 2022-09-08 05:57:41 default[20220908t055413] [2022-09-08 05:57:41 +0000] [11] [INFO] Shutting down: Master
The main problem as per my best guess occurs here:
[INFO] Handling signal: term
2022-09-08 05:57:36 default[20220908t054903] [2022-09-08 05:57:36 +0000] [10] [WARNING] Worker with pid 21 was terminated due to signal 15
2022-09-08 05:57:36 default[20220908t054903] [2022-09-08 05:57:36 +0000] [10] [WARNING] Worker with pid 19 was terminated due to signal 15
2022-09-08 05:57:36 default[20220908t054903] [2022-09-08 05:57:36 +0000] [10] [WARNING] Worker with pid 16 was terminated due to signal 15
2022-09-08 05:57:36 default[20220908t054903] [2022-09-08 05:57:36 +0000] [10] [WARNING] Worker with pid 20 was terminated due to signal 15
2022-09-08 05:57:36 default[20220908t054903] [2022-09-08 05:57:36 +0000] [10] [INFO] Shutting down: Master
You have from app.routes.routes import router as appRoutes;
There is a semicolon (no semicolon in Python)
You have from app.routes but app is not defined till later (after 1 line) where you have app = FastAPI()
In essence, you need to move the line (without the semicolon) from app.routes.routes import router as appRoutes to after app = FastAPI()

Gunicorn as Service not recognizing Python dependencies

I am running a Flask app on a Ubuntu Linode Server using Gunicorn to serve the app and nginx as a reverse proxy.
I have one app running successfully, but I have a second app where I'm running in to the following problem.
What does work
when I run FLASK_APP=tester.py python3 -m flask run
This works, tester.py runs the app bound to 0.0.0.0 on port 5100 and I can access it from my browser.
when I run gunicorn --bind 0.0.0.0:5100 wsgi:app
This also works, as my wsgi.py imports my app object making it accessible for wsgi
Useful details
which python gives me /usr/bin/python
which pip gives /usr/bin/pip and which pip3 gives /usr/bin/pip3
which python3 gives me /usr/bin/python3
which gunicorn gives me /usr/bin/gunicorn
I am not using a virtual environment since boths app have near identical dependencies
What's not working
I created a service for forwarding traffic with nginx with:
/etc/systemd/system/testpad.service
[Unit]
# specifies metadata and dependencies
Description=Gunicorn instance to serve myproject
After=network.target
# tells the init system to only start this after the networking target has been reached
# We will give our regular user account ownership of the process since it owns all of the relevant files
[Service]
# Service specify the user and group under which our process will run.
User=www-data
# give group ownership to the www-data group so that Nginx can communicate easily with the Gunicorn processes.
Group=www-data
# We'll then map out the working directory and set the PATH environmental variable so that the init system knows where our the executabl>
WorkingDirectory=/home/xxx/xxx
# We'll then specify the commanded to start the service
ExecStart=/usr/bin/gunicorn --bind unix:testpad.sock --access-logfile /home/xxx/xxx/accesslog --error-logfile /home/xxx/xxx/errorlog -m 007 wsgi:app
# This will tell systemd what to link this service to if we enable it to start at boot. We want this service to start when the regular m>
[Install]
WantedBy=multi-user.target
when I start the service it runs for a second then I get this from sudo systemctl status testpad
testpad.service - Gunicorn instance to serve myproject
Loaded: loaded (/etc/systemd/system/testpad.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2021-09-06 15:47:59 UTC; 16min ago
Process: 655575 ExecStart=/usr/bin/gunicorn --bind unix:testpad.sock --access-logfile /home/xxx/xxx/acces>
Main PID: 655575 (code=exited, status=1/FAILURE)
Sep 06 15:47:54 microportalbeta systemd[1]: Started Gunicorn instance to serve myproject.
Sep 06 15:47:59 microportalbeta systemd[1]: testpad.service: Main process exited, code=exited, status=1/FAILURE
Sep 06 15:47:59 microportalbeta systemd[1]: testpad.service: Failed with result 'exit-code'.
so when I cat errorlog I get
[2021-09-06 15:21:31 +0000] [655222] [INFO] Worker exiting (pid: 655222)
[2021-09-06 15:21:31 +0000] [655223] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/gunicorn/arbiter.py", line 589, in spawn_worker
worker.init_process()
File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 134, in init_process
self.load_wsgi()
File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 146, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/lib/python3/dist-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/lib/python3/dist-packages/gunicorn/app/wsgiapp.py", line 58, in load
return self.load_wsgiapp()
File "/usr/lib/python3/dist-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/lib/python3/dist-packages/gunicorn/util.py", line 384, in import_app
mod = importlib.import_module(module)
File "/usr/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 855, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/home/xxx/xxx/wsgi.py", line 1, in <module>
from run import app
File "/home/xxx/xxx/run.py", line 1, in <module>
from genedflask import create_app, db
File "/home/xxx/xxx/xxx/__init__.py", line 5, in <module>
from flask_login import LoginManager
ModuleNotFoundError: No module named 'flask_login'
[2021-09-06 15:21:31 +0000] [655223] [INFO] Worker exiting (pid: 655223)
[2021-09-06 15:21:32 +0000] [655220] [WARNING] Worker with pid 655223 was terminated due to signal 15
[2021-09-06 15:21:32 +0000] [655220] [WARNING] Worker with pid 655222 was terminated due to signal 15
[2021-09-06 15:21:32 +0000] [655220] [INFO] Shutting down: Master
[2021-09-06 15:21:32 +0000] [655220] [INFO] Reason: Worker failed to boot.
[2021-09-06 15:23:34 +0000] [655249] [INFO] Starting gunicorn 20.1.0
[2021-09-06 15:23:34 +0000] [655249] [ERROR] Retrying in 1 second.
[2021-09-06 15:23:35 +0000] [655249] [ERROR] Retrying in 1 second.
[2021-09-06 15:23:36 +0000] [655249] [ERROR] Retrying in 1 second.
[2021-09-06 15:23:37 +0000] [655249] [ERROR] Retrying in 1 second.
[2021-09-06 15:23:38 +0000] [655249] [ERROR] Retrying in 1 second.
[2021-09-06 15:23:39 +0000] [655249] [ERROR] Can't connect to testpad.sock
[2021-09-06 15:28:44 +0000] [655315] [INFO] Starting gunicorn 20.1.0
[2021-09-06 15:28:44 +0000] [655315] [ERROR] Retrying in 1 second.
[2021-09-06 15:28:45 +0000] [655315] [ERROR] Retrying in 1 second.
[2021-09-06 15:28:46 +0000] [655315] [ERROR] Retrying in 1 second.
[2021-09-06 15:28:47 +0000] [655315] [ERROR] Retrying in 1 second.
[2021-09-06 15:28:48 +0000] [655315] [ERROR] Retrying in 1 second.
[2021-09-06 15:28:49 +0000] [655315] [ERROR] Can't connect to testpad.sock
[2021-09-06 15:31:09 +0000] [655348] [INFO] Starting gunicorn 20.1.0
[2021-09-06 15:31:09 +0000] [655348] [ERROR] Retrying in 1 second.
[2021-09-06 15:31:10 +0000] [655348] [ERROR] Retrying in 1 second.
[2021-09-06 15:31:11 +0000] [655348] [ERROR] Retrying in 1 second.
[2021-09-06 15:31:12 +0000] [655348] [ERROR] Retrying in 1 second.
[2021-09-06 15:31:13 +0000] [655348] [ERROR] Retrying in 1 second.
[2021-09-06 15:31:14 +0000] [655348] [ERROR] Can't connect to testpad.sock
[2021-09-06 15:33:34 +0000] [655387] [INFO] Starting gunicorn 20.1.0
[2021-09-06 15:33:34 +0000] [655387] [ERROR] Retrying in 1 second.
[2021-09-06 15:33:35 +0000] [655387] [ERROR] Retrying in 1 second.
[2021-09-06 15:33:36 +0000] [655387] [ERROR] Retrying in 1 second.
[2021-09-06 15:33:37 +0000] [655387] [ERROR] Retrying in 1 second.
[2021-09-06 15:33:38 +0000] [655387] [ERROR] Retrying in 1 second.
[2021-09-06 15:33:39 +0000] [655387] [ERROR] Can't connect to testpad.sock
[2021-09-06 15:47:54 +0000] [655575] [INFO] Starting gunicorn 20.1.0
[2021-09-06 15:47:54 +0000] [655575] [ERROR] Retrying in 1 second.
[2021-09-06 15:47:55 +0000] [655575] [ERROR] Retrying in 1 second.
[2021-09-06 15:47:56 +0000] [655575] [ERROR] Retrying in 1 second.
[2021-09-06 15:47:57 +0000] [655575] [ERROR] Retrying in 1 second.
[2021-09-06 15:47:58 +0000] [655575] [ERROR] Retrying in 1 second.
[2021-09-06 15:47:59 +0000] [655575] [ERROR] Can't connect to testpad.sock
Not sure why it is not finding flask-login as it is installed under pip and pip3 globally, and is visible when I run pip3 list or pip list.
I assume that once I overcome this hurdle then the testpad.sock file should auto create as it did with my previous app. Most people with this problem I found it was an issue with gunicorn looking at the global environment when people installed dependencies in a virtual environment, which I am not doing in this circumstance.
Any suggestions?
Update
I never did figure out why it could not find the libraries when ran as a service, I even set the PYTHONPATH variable to see if that would help.
What I did do is give up on running as a service and instead just ran the application as a background process on port 8000 and just directed nginx to forward traffic there, and that worked.

Some YARN worker node not join cluster , while I create spark cluster on Dataproc

I have created a spark cluster on dataproc with 1 master and 6 worker node.
On GCP console I can see 6 VMs are running, but I only see 5 nodes on YARN Node Manager UI.
When I ssh into that machine, from the yarn-yarn-nodemanager log, I see, it keeps restarting and reconnecting to NodeManager.
How can I make this node rejoin cluster ?
update: my command
gcloud dataproc clusters create ${GCS_CLUSTER} \
--image pyspark-with-conda \
--bucket test-spark-data \
--zone asia-east1-b \
--master-boot-disk-size 500GB \
--master-machine-type n1-standard-2 \
--num-masters 1 \
--num-workers 2 \
--worker-machine-type n1-standard-8 \
--num-preemptible-workers 4 \
--preemptible-worker-boot-disk-size 500GB
Error message:
2018-08-22 08:25:24,801 INFO org.apache.hadoop.yarn.client.RMProxy: Connecting to ResourceManager at test-spark-cluster-m/10.140.0.34:8031
2018-08-22 08:25:24,836 INFO org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdaterImpl: Sending out 0 NM container statuses: []
2018-08-22 08:25:24,843 INFO org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdaterImpl: Registering with RM using containers :[]
2018-08-22 08:25:24,978 ERROR org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdaterImpl: Unexpected error starting NodeStatusUpdater
org.apache.hadoop.yarn.exceptions.YarnRuntimeException: Recieved SHUTDOWN signal from Resourcemanager, Registration of NodeManager failed, Message from ResourceManager: Disallowed NodeManager from test-spark-cluster-sw-kbvq.c.test-155104.internal, Sending SHUTDOWN signal to the NodeManager.
at org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdaterImpl.registerWithRM(NodeStatusUpdaterImpl.java:374)
at org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdaterImpl.serviceStart(NodeStatusUpdaterImpl.java:252)
at org.apache.hadoop.service.AbstractService.start(AbstractService.java:194)
at org.apache.hadoop.service.CompositeService.serviceStart(CompositeService.java:121)
at org.apache.hadoop.yarn.server.nodemanager.NodeManager.serviceStart(NodeManager.java:454)
at org.apache.hadoop.service.AbstractService.start(AbstractService.java:194)
at org.apache.hadoop.yarn.server.nodemanager.NodeManager.initAndStartNodeManager(NodeManager.java:837)
at org.apache.hadoop.yarn.server.nodemanager.NodeManager.main(NodeManager.java:897)
2018-08-22 08:25:24,979 INFO org.apache.hadoop.service.AbstractService: Service org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdaterImpl failed in state STARTED; cause: org.apache.hadoop.yarn.exceptions.YarnRuntimeException: org.apach
e.hadoop.yarn.exceptions.YarnRuntimeException: Recieved SHUTDOWN signal from Resourcemanager, Registration of NodeManager failed, Message from ResourceManager: Disallowed NodeManager from test-spark-cluster-sw-kbvq.c.test-155104.internal,
Sending SHUTDOWN signal to the NodeManager.
org.apache.hadoop.yarn.exceptions.YarnRuntimeException: org.apache.hadoop.yarn.exceptions.YarnRuntimeException: Recieved SHUTDOWN signal from Resourcemanager, Registration of NodeManager failed, Message from ResourceManager: Disallowed NodeM
anager from test-spark-cluster-sw-kbvq.c.test-155104.internal, Sending SHUTDOWN signal to the NodeManager.
at org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdaterImpl.serviceStart(NodeStatusUpdaterImpl.java:258)
at org.apache.hadoop.service.AbstractService.start(AbstractService.java:194)
at org.apache.hadoop.service.CompositeService.serviceStart(CompositeService.java:121)
at org.apache.hadoop.yarn.server.nodemanager.NodeManager.serviceStart(NodeManager.java:454)
at org.apache.hadoop.service.AbstractService.start(AbstractService.java:194)
at org.apache.hadoop.yarn.server.nodemanager.NodeManager.initAndStartNodeManager(NodeManager.java:837)
at org.apache.hadoop.yarn.server.nodemanager.NodeManager.main(NodeManager.java:897)
Caused by: org.apache.hadoop.yarn.exceptions.YarnRuntimeException: Recieved SHUTDOWN signal from Resourcemanager, Registration of NodeManager failed, Message from ResourceManager: Disallowed NodeManager from test-spark-cluster-sw-kbvq.c.pv
max-155104.internal, Sending SHUTDOWN signal to the NodeManager.
at org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdaterImpl.registerWithRM(NodeStatusUpdaterImpl.java:374)
at org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdaterImpl.serviceStart(NodeStatusUpdaterImpl.java:252)
... 6 more
2018-08-22 08:25:25,081 INFO org.apache.hadoop.service.AbstractService: Service NodeManager failed in state STARTED; cause: org.apache.hadoop.yarn.exceptions.YarnRuntimeException: org.apache.hadoop.yarn.exceptions.YarnRuntimeException: Recie
ved SHUTDOWN signal from Resourcemanager, Registration of NodeManager failed, Message from ResourceManager: Disallowed NodeManager from test-spark-cluster-sw-kbvq.c.test-155104.internal, Sending SHUTDOWN signal to the NodeManager.
org.apache.hadoop.yarn.exceptions.YarnRuntimeException: org.apache.hadoop.yarn.exceptions.YarnRuntimeException: Recieved SHUTDOWN signal from Resourcemanager, Registration of NodeManager failed, Message from ResourceManager: Disallowed NodeM
anager from test-spark-cluster-sw-kbvq.c.test-155104.internal, Sending SHUTDOWN signal to the NodeManager.
at org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdaterImpl.serviceStart(NodeStatusUpdaterImpl.java:258)
at org.apache.hadoop.service.AbstractService.start(AbstractService.java:194)
at org.apache.hadoop.service.CompositeService.serviceStart(CompositeService.java:121)
at org.apache.hadoop.yarn.server.nodemanager.NodeManager.serviceStart(NodeManager.java:454)
at org.apache.hadoop.service.AbstractService.start(AbstractService.java:194)
at org.apache.hadoop.yarn.server.nodemanager.NodeManager.initAndStartNodeManager(NodeManager.java:837)
at org.apache.hadoop.yarn.server.nodemanager.NodeManager.main(NodeManager.java:897)
Caused by: org.apache.hadoop.yarn.exceptions.YarnRuntimeException: Recieved SHUTDOWN signal from Resourcemanager, Registration of NodeManager failed, Message from ResourceManager: Disallowed NodeManager from test-spark-cluster-sw-kbvq.c.pv
max-155104.internal, Sending SHUTDOWN signal to the NodeManager.
at org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdaterImpl.registerWithRM(NodeStatusUpdaterImpl.java:374)
at org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdaterImpl.serviceStart(NodeStatusUpdaterImpl.java:252)
... 6 more
2018-08-22 08:25:25,084 INFO org.mortbay.log: Stopped HttpServer2$SelectChannelConnectorWithSafeStartup#0.0.0.0:8042
2018-08-22 08:25:25,185 INFO org.apache.hadoop.ipc.Server: Stopping server on 60144
2018-08-22 08:25:25,186 INFO org.apache.hadoop.ipc.Server: Stopping IPC Server listener on 60144
2018-08-22 08:25:25,186 INFO org.apache.hadoop.ipc.Server: Stopping IPC Server Responder
2018-08-22 08:25:25,187 WARN org.apache.hadoop.yarn.server.nodemanager.containermanager.monitor.ContainersMonitorImpl: org.apache.hadoop.yarn.server.nodemanager.containermanager.monitor.ContainersMonitorImpl is interrupted. Exiting.
2018-08-22 08:25:25,204 INFO org.apache.hadoop.ipc.Server: Stopping server on 8040
2018-08-22 08:25:25,204 INFO org.apache.hadoop.ipc.Server: Stopping IPC Server listener on 8040
2018-08-22 08:25:25,205 INFO org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.ResourceLocalizationService: Public cache exiting
2018-08-22 08:25:25,205 INFO org.apache.hadoop.ipc.Server: Stopping IPC Server Responder
2018-08-22 08:25:25,205 WARN org.apache.hadoop.yarn.server.nodemanager.NodeResourceMonitorImpl: org.apache.hadoop.yarn.server.nodemanager.NodeResourceMonitorImpl is interrupted. Exiting.
2018-08-22 08:25:25,205 INFO org.apache.hadoop.metrics2.impl.MetricsSystemImpl: Stopping NodeManager metrics system...
2018-08-22 08:25:25,206 INFO org.apache.hadoop.metrics2.impl.MetricsSystemImpl: NodeManager metrics system stopped.
2018-08-22 08:25:25,206 INFO org.apache.hadoop.metrics2.impl.MetricsSystemImpl: NodeManager metrics system shutdown complete.
2018-08-22 08:25:25,206 ERROR org.apache.hadoop.yarn.server.nodemanager.NodeManager: Error starting NodeManager
org.apache.hadoop.yarn.exceptions.YarnRuntimeException: org.apache.hadoop.yarn.exceptions.YarnRuntimeException: Recieved SHUTDOWN signal from Resourcemanager, Registration of NodeManager failed, Message from ResourceManager: Disallowed NodeM
anager from test-spark-cluster-sw-kbvq.c.test-155104.internal, Sending SHUTDOWN signal to the NodeManager.
at org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdaterImpl.serviceStart(NodeStatusUpdaterImpl.java:258)
at org.apache.hadoop.service.AbstractService.start(AbstractService.java:194)
at org.apache.hadoop.service.CompositeService.serviceStart(CompositeService.java:121)
at org.apache.hadoop.yarn.server.nodemanager.NodeManager.serviceStart(NodeManager.java:454)
at org.apache.hadoop.service.AbstractService.start(AbstractService.java:194)
at org.apache.hadoop.yarn.server.nodemanager.NodeManager.initAndStartNodeManager(NodeManager.java:837)
at org.apache.hadoop.yarn.server.nodemanager.NodeManager.main(NodeManager.java:897)
Caused by: org.apache.hadoop.yarn.exceptions.YarnRuntimeException: Recieved SHUTDOWN signal from Resourcemanager, Registration of NodeManager failed, Message from ResourceManager: Disallowed NodeManager from test-spark-cluster-sw-kbvq.c.pv
max-155104.internal, Sending SHUTDOWN signal to the NodeManager.
at org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdaterImpl.registerWithRM(NodeStatusUpdaterImpl.java:374)
at org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdaterImpl.serviceStart(NodeStatusUpdaterImpl.java:252)
... 6 more
2018-08-22 08:25:25,208 INFO org.apache.hadoop.yarn.server.nodemanager.NodeManager: SHUTDOWN_MSG:
/************************************************************
OP confirmed that this issue is resolved and they didn't encounter it anymore.

serving flask app using gunicorn + nginx showing 404 [ec2]

I am trying to serve a simple API by following this digitalocean tutorial.
For testing I was earlier serving the API through gunicorn by doing a
$ gunicorn --bind 0.0.0.0:5000 trumporate.wsgi:app
And curling the API endpoint works inside the ec2 box
$ curl -X GET http://0.0.0.0:5000/api/v1/trump/rant/
{
"foo": "bar"
}
Now I shifted this gunicorn process to run at startup by making a systemd service
# /etc/systemd/system/trumporate.service
[Unit]
Description=Gunicorn instance for trumporate
After=network.target
[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/var/opt/trumporate
ExecStart=/usr/local/bin/gunicorn --workers 3 --bind unix:trumporate.sock -m 007 --access-logfile /var/log/trumporate/gunicorn-access.log --error-logfile /var/log/trumporate/gunicorn-error.log trumporate.wsgi:app
[Install]
WantedBy=multi-user.target
I have created the files
/var/log/trumporate/gunicorn-error.log
/var/log/trumporate/gunicorn-access.log
and changed the ownership and group to ubuntu
After enabling the service and rebooting, I checked the status
$ sudo systemctl status trumporate.service
● trumporate.service - Gunicorn instance for trumporate
Loaded: loaded (/etc/systemd/system/trumporate.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2017-05-03 06:30:26 UTC; 1h 2min ago
Main PID: 1122 (gunicorn)
Tasks: 4
Memory: 92.2M
CPU: 1.390s
CGroup: /system.slice/trumporate.service
├─1122 /usr/bin/python3 /usr/local/bin/gunicorn --workers 3 --bind unix:trumporate.sock -m 007 --access-logfile /var/log/trumporate/gunicorn-access.log --error-logfile /var/log/trumporate/gunic
├─1264 /usr/bin/python3 /usr/local/bin/gunicorn --workers 3 --bind unix:trumporate.sock -m 007 --access-logfile /var/log/trumporate/gunicorn-access.log --error-logfile /var/log/trumporate/gunic
├─1266 /usr/bin/python3 /usr/local/bin/gunicorn --workers 3 --bind unix:trumporate.sock -m 007 --access-logfile /var/log/trumporate/gunicorn-access.log --error-logfile /var/log/trumporate/gunic
└─1267 /usr/bin/python3 /usr/local/bin/gunicorn --workers 3 --bind unix:trumporate.sock -m 007 --access-logfile /var/log/trumporate/gunicorn-access.log --error-logfile /var/log/trumporate/gunic
May 03 06:30:26 ip-172-31-25-173 systemd[1]: Started Gunicorn instance for trumporate.
Following the DO tutorial, I tried configuring nginx to proxy incoming requests on port 80
$ cat /etc/nginx/sites-available/trumporate
server {
listen 80;
server_name private_ip_address;
location / {
include proxy_params;
proxy_pass http://unix:/var/opt/trumporate/trumporate.sock;
}
}
And then did a
$ ln -s /etc/nginx/sites-available/trumporate /etc/nginx/sites-enabled
$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Now if I try to do GET request to the API endpoint from outside the ec2 box
$ curl -X GET http://public_ip/api/v1/trump/rant
<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.10.0 (Ubuntu)</center>
</body>
</html>
Same case when I try to do it from inside the ec2 container too
$ curl -X GET http://localhost:80/api/v1/trump/rant/
<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.10.0 (Ubuntu)</center>
</body>
</html>
log files
# /var/log/nginx/access.log
dev_box_ip - - [03/May/2017:05:50:45 +0000] "GET /api/v1/trump/rant/ HTTP/1.1" 404 580 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36"
127.0.0.1 - - [03/May/2017:06:13:26 +0000] "GET /api/v1/trump/rant/ HTTP/1.1" 404 178 "-" "curl/7.47.0"
dev_box_ip - - [03/May/2017:07:42:42 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36"
/var/log/nginx$ cat error.log
/var/log/nginx$
/var/log/trumporate$ cat gunicorn-access.log
/var/log/trumporate$
$ cat gunicorn-error.log
[2017-05-03 06:28:41 +0000] [1884] [INFO] Starting gunicorn 19.7.1
[2017-05-03 06:28:41 +0000] [1884] [INFO] Listening at: unix:trumporate.sock (1884)
[2017-05-03 06:28:41 +0000] [1884] [INFO] Using worker: sync
[2017-05-03 06:28:41 +0000] [1889] [INFO] Booting worker with pid: 1889
[2017-05-03 06:28:41 +0000] [1890] [INFO] Booting worker with pid: 1890
[2017-05-03 06:28:41 +0000] [1891] [INFO] Booting worker with pid: 1891
[2017-05-03 06:29:48 +0000] [1884] [INFO] Handling signal: term
[2017-05-03 06:29:48 +0000] [1889] [INFO] Worker exiting (pid: 1889)
[2017-05-03 06:29:48 +0000] [1890] [INFO] Worker exiting (pid: 1890)
[2017-05-03 06:29:48 +0000] [1891] [INFO] Worker exiting (pid: 1891)
[2017-05-03 06:29:49 +0000] [1884] [INFO] Shutting down: Master
[2017-05-03 06:30:27 +0000] [1122] [INFO] Starting gunicorn 19.7.1
[2017-05-03 06:30:27 +0000] [1122] [INFO] Listening at: unix:trumporate.sock (1122)
[2017-05-03 06:30:27 +0000] [1122] [INFO] Using worker: sync
[2017-05-03 06:30:27 +0000] [1264] [INFO] Booting worker with pid: 1264
[2017-05-03 06:30:27 +0000] [1266] [INFO] Booting worker with pid: 1266
[2017-05-03 06:30:28 +0000] [1267] [INFO] Booting worker with pid: 1267
/var/log/trumporate$
EDIT
Relevant part of the flask app
#app.route('/api/v1/trump/rant/')
def return_rant():
foo = # logic
return jsonify(rant=foo)
Did you do nginx -s reload && systemctl restart nginx?
Another thing which you could try is to make the bindings on a http port instead of a socket:
--bind 127.0.0.1:6767 #in systemd config
and change nginx config as follows:
location / {
include proxy_params;
proxy_redirect off;
proxy_pass http://127.0.0.1:6767;
}
Also why do you have private_ip in nginx config?
server_name private_ip_address;
Change that to
server_name "_";
# OR
server_name PUBLIC_IP;
and remove all default configs from /etc/nginx/site-enabled
1) use of server_name private_ip_address;?
Nginx uses the server_name to check with the host header of the incoming request, and that isn't the private address. (You usually access using either a domain name or the public address in the URL bar)
2) I deleted /etc/nginx/site-enabled/default dir to make things to get to working.
If your server_name is not set correctly, nginx processes the request using the default file or the server block containing default_server. Thus I asked you to delete that file just in case there was an issue with your server name ^_^
Also, what difference would it make to the performance of the API if I am binding it to a port instead of the socket file as suggested by the blog post?
This would typically be premature optimization, any difference you get will purely be within a margin of error compared to the bottlenecks caused by flask/python and especially database connections. Though please take this with a grain of salt as I do not have any reliable source to quote this on.

Resources