hi
IN Lab : Python Deply Flask Q 9 below is the question and hint
=============================================================
Question
Run Gunicorn with 3 workers in background and confirm with curl
Check
- info_outline Hint
Stop previously started process by pressing Ctrl + C
. Run nohup gunicorn app:app -w 3 &
and curl localhost:8000
-
Tasks not completed!
-
Check gunicorn running with 3 workers?
===========================================================
Result :
The checks does not pass . Can you please review and confirm why ?
I have included the output of "tail -f /home/thor/nohup.out " and output of " ps -ef | grep gunicorn " for verification.
Below is my working
=============================================================
thor@host01 /opt/simple-webapp-flask$
thor@host01 /opt/simple-webapp-flask$ nohup gunicorn app:app -w 3 &
[1] 214
thor@host01 /opt/simple-webapp-flask$ nohup: ignoring input and appending output to ‘/home/thor/nohup.out’
thor@host01 /opt/simple-webapp-flask$ curl localhost:8000
Welcome!thor@host01 /opt/simple-webapp-flask$
thor@host01 /opt/simple-webapp-flask$
thor@host01 /opt/simple-webapp-flask$ ps -ef | grep gunicorn
thor 178 1 0 20:15 pts/1 00:00:00 [gunicorn] <defunct>
thor 214 47 0 20:23 pts/1 00:00:00 /usr/bin/python2 /usr/bin/gunicorn app:app -w 3
thor 219 214 0 20:23 pts/1 00:00:00 /usr/bin/python2 /usr/bin/gunicorn app:app -w 3
thor 224 214 0 20:23 pts/1 00:00:00 /usr/bin/python2 /usr/bin/gunicorn app:app -w 3
thor 228 214 0 20:23 pts/1 00:00:00 /usr/bin/python2 /usr/bin/gunicorn app:app -w 3
thor 237 47 0 20:24 pts/1 00:00:00 grep --color=auto gunicorn
thor@host01 /opt/simple-webapp-flask$
thor@host01 /opt/simple-webapp-flask$ pwd
/opt/simple-webapp-flask
thor@host01 /opt/simple-webapp-flask$
thor@host01 /opt/simple-webapp-flask$ ls -al
total 32
drwxr-xr-x 3 root root 4096 Jan 19 20:11 .
drwxr-xr-x 1 root root 4096 Jan 19 20:09 ..
-rw-r--r-- 1 root root 254 Jan 19 20:11 app.py
-rw-r--r-- 1 root root 187 Jan 19 20:09 Dockerfile
drwxr-xr-x 8 root root 4096 Jan 19 20:09 .git
-rw-r--r-- 1 root root 1075 Jan 19 20:09 LICENSE
-rw-r--r-- 1 root root 1081 Jan 19 20:09 README.md
-rw-r--r-- 1 root root 6 Jan 19 20:09 requirements.txt
thor@host01 /opt/simple-webapp-flask$
thor@host01 /opt/simple-webapp-flask$ tail -f /home/thor/nohup.out
[2021-01-19 20:15:31 +0000] [173] [INFO] Starting gunicorn 19.10.0
[2021-01-19 20:15:31 +0000] [173] [INFO] Listening at: http://127.0.0.1:8000 (173)
[2021-01-19 20:15:31 +0000] [173] [INFO] Using worker: sync
[2021-01-19 20:15:31 +0000] [178] [INFO] Booting worker with pid: 178
[2021-01-19 20:23:03 +0000] [214] [INFO] Starting gunicorn 19.10.0
[2021-01-19 20:23:03 +0000] [214] [INFO] Listening at: http://127.0.0.1:8000 (214)
[2021-01-19 20:23:03 +0000] [214] [INFO] Using worker: sync
[2021-01-19 20:23:03 +0000] [219] [INFO] Booting worker with pid: 219
[2021-01-19 20:23:03 +0000] [224] [INFO] Booting worker with pid: 224
[2021-01-19 20:23:03 +0000] [228] [INFO] Booting worker with pid: 228
^C
thor@host01 /opt/simple-webapp-flask$
thor@host01 /opt/simple-webapp-flask$
thor@host01 /opt/simple-webapp-flask$ history
1 cd /opt
2 sudo git clone https://github.com/mmumshad/simple-webapp-flask
3 pwd
4 ls -al
5 cd simple-webapp-flask/
6 ls -al
7 sudo pip install -r requirements.txt
8 alias c=clear
9 c
10 cat app.py
11 sudo sed -i 's/8080/5000/g' app.py
12 cat app.py
13 sudo python app.py
14 nohup python app.py &
15 c
16 clear
17 ps -ef | grep app
18 kill -9 python
19 kill -9 140
20 ps -ef | grep app
21 c
22 sudo pip install gunicorn
23 nohup gunicorn app:app &
24 ps -ef | grep gunicorn
25 ls -al
26 tail -f /home/thor/nohup.out
27 cat app.py
28 ps -ef | grep gunicorn
29 curl localhost:8000
30 curl localhost:5000
31 curl www.localhost:5000/app
32 kill -9 173 178
33 curl localhost:5000
34 curl localhost:8000
35 ps -ef | grep gunicorn
36 c
37 ps -ef | grep gunicorn
38 c
39 nohup gunicorn app:app -w 3 &
40 curl localhost:8000
41 ps -ef | grep gunicorn
42 pwd
43 ls -al
44 tail -f /home/thor/nohup.out
45 history
thor@host01 /opt/simple-webapp-flask$
thor@host01 /opt/simple-webapp-flask$
Checks :
- info_outline Hint
Stop previously started process by pressing Ctrl + C
. Run nohup gunicorn app:app -w 3 &
and curl localhost:8000
-
Tasks not completed!
-
Check gunicorn running with 3 workers?