0

I'm running nginx, gunincorn (to start flask). When i kill nginx, the nginx test page disappears, but gunicorn/flask app continue to serve.

  1. Is this expected?
  2. How can i ensure gunicorn/nginx are working together?
  3. I also checked the nginx access log and I don't see requests to the port that gunicorn/flask are bound to.

My process

  1. Install nginx
  2. Install gunicorn
  3. Setup nginx

Nginx setup

cd /etc/nginx
mkdir sites-available
mkdir sites-enabled
vim /sites-available/my_site
server {
    location / {
        proxy_pass http://localhost:9000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}
dzdo ln -s ../sites-available/my_site my_site

Nginx conf

user  nginx;
worker_processes  1;
error_log  /var/log/nginx/error.log;
pid        /run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    keepalive_timeout  65;
    include /etc/nginx/conf.d/*.conf;
    index   index.html index.htm;
    server {
        listen       90;
        server_name  localhost;
        root         /usr/share/nginx/html;

        location / {
        }

        error_page  404              /404.html;
        location = /40x.html {
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
        }
    }

    server {
       listen 9001;
       server_name localhost;
       root /tmp/html/;

       location / {
       }
    }
}

Gunicorn start

gunicorn –bind 0.0.0.0:9000 “my_site.driver:create_app()” &
ivrin
  • 103
  • 3

1 Answers1

0
  1. Yes because nginx and gunicorn are different processes from each other. When you kill nginx process, gunicorn process still working.

  2. You can use monitoring tool for that such as naemon. You can check nginx and gunicorn processes separately and you can ensure that they are working .

  3. This is also normal. Because default nginx logging configuration is not provide this information. ( and I don't know is is possible)

fyarci
  • 114