Check to see if the port number is occupied

Netstat anp | grep 8080 click and drag to move to see the progress of the application

Ps aux | grep nginx click and drag to move the flask parts first flask writing service omit (business related)

The Gunicorn part First of all our Flask project is started as follows:

App. Run (host=”0.0.0.0″,use_reloader=True, port=5000) Click and drag to move the app. If we use gunicorn to boot, we don’t need to write the port number, we can use gunicorn to set the port number to boot

The flask service is started as

App. Run (debug=False) Click and drag to move to boot using Gunicorn

The original worker 4 command has four threads

Gunicorn-w 4 manage:app Click and drag to move

When our app was built using factory functions

Gunicorn -w 4 “my_project:create_app()” Click and drag to complete the above steps to start the flask using gunicorn

The Supervisor part is mainly to complete the configuration of the Gunicorn

We started flask with gunicorn using four processes (four threads each)

[program:gunicorn] command=gunicorn -w 4 “manage:create_app()” -b :8091 directory=/home/a21036/waws priority=1 numprocs=1 autostart=true autorestart=true startretries=10 exitcodes=0 stopsignal=KILL stopwaitsecs=10 redirect_stderr=true [program:gunicorn_1] command=gunicorn -w 4 “manage:create_app()” -b :8092 directory=/home/a21036/waws/ priority=1 numprocs=1 autostart=true autorestart=true startretries=10 exitcodes=0 stopsignal=KILL stopwaitsecs=10 redirect_stderr=true [program:gunicorn_2] command=gunicorn -w 4 “manage:create_app()” -b :8093 directory=/home/a21036/waws/ priority=1 numprocs=1 autostart=true autorestart=true startretries=10 exitcodes=0 stopsignal=KILL stopwaitsecs=10 redirect_stderr=true [program:gunicorn_3] command=gunicorn -w 4 “manage:create_app()” -b :8094 directory=/home/a21036/waws/ numprocs=1 autostart=true autorestart=true startretries=10 exitcodes=0 StopSignal =KILL stopWaitSecs =10 redirect_stderr=true Click and drag to move our Supervisor to start using the following command

Supervisord – c/usr/supervisor/supervisor. Click and drag to move the conf If we have launched the supervisor, we use the following command to start

The supervisorctl start gunicorn1 start gunicorn2 start gunicorn3 Click and drag to make the mobile supervisorctl start all The Click-and-Drag to Move Nginx section is designed to load balance the four services started, considering the concurrency of the application

Upstream. Conf controls the actual listening port for backend.conf to implement the operation

upstream.conf

upstream backends {

 server localhost:9001;
 server localhost:9002;
 server localhost:9003;
 server localhost:9004;

}

server {

 listen 80;
 location / {
 proxy_pass 

}} Click and drag to move backend.conf

server {

 listen localhost:9001;
 location ^~ /static/ {
    alias /home/a21036/static/;
    autoindex on;
 }
 location = /upload {
    proxy_pass 
    proxy_redirect off;
    proxy_set_header Host $http_post;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 }
 location =/ {
     proxy_pass 
     proxy_redirect off;
     proxy_set_header Host $http_post;
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 }

}

server {

 listen localhost:9002;
 location ^~ /static/ {
    alias /home/a21036/static/;
    autoindex on;
 }
 location = /upload {
    proxy_pass 
    proxy_redirect off;
    proxy_set_header Host $http_post;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 }
 location =/ {
     proxy_pass 
     proxy_redirect off;
     proxy_set_header Host $http_post;
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 }

}

server {

 listen localhost:9003;
 location ^~ /static/ {
    alias /home/a21036/static/;
    autoindex on;
 }
 location = /upload {
    proxy_pass 
    proxy_redirect off;
    proxy_set_header Host $http_post;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 }
 location =/ {
     proxy_pass 
     proxy_redirect off;
     proxy_set_header Host $http_post;
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 }

}

server {

 listen localhost:9004;
 location ^~ /static/ {
    alias /home/a21036/static/;
    autoindex on;
 }
 location = /upload {
    proxy_pass 
    proxy_redirect off;
    proxy_set_header Host $http_post;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 }
 location =/ {
     proxy_pass 
     proxy_redirect off;
     proxy_set_header Host $http_post;
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 }

} Clicking and dragging to move made a serious error in this place:

server {

listen localhost:8094; {alias /home/a21036/static/; autoindex on; } location = /upload { proxy_pass proxy_redirect off; proxy_set_header Host $http_post; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location =/ { proxy_pass proxy_redirect off; proxy_set_header Host www.sangpi.com$http_post; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }

} Click and drag to move the actual error cause: We used the supervisor to start gunicorn and started the service of 8094. Then we listened to 8094 using nginx, which caused the problem of port being taken up. I have found that we need to use other ports to listen to 8094, and we use 9004 to monitor 8094 here

Our nginx will be started without being started using the following command

If we have started nginx, we use the following command to reload the configuration file

Check that our nginx configuration syntax is not a problem

/usr/sbin/nginx -t

Reloading the configuration file

/usr/sbin/ nginx-s reload: /usr/sbin/ nginx-s reload: /usr/sbin/ nginx-s reload: /usr/sbin/ nginx-s reload: /usr/sbin/ nginx-s reload: /usr/sbin/ nginx-s reload: /usr/sbin/ nginx-s reload: /usr/sbin/ nginx-s reload: /usr/sbin/ nginx-s reload: /usr/sbin/ nginx-s reload

View mode 1

Tail -f XXXX. Log # Newly generated logs are viewed in a scrolling manner

View mode 2

Click and drag to move Nginx’s two main logs to /var/log/nginx