Skip to content

Commit b2bc4f4

Browse files
committedJun 29, 2020
.
1 parent 654264c commit b2bc4f4

File tree

3 files changed

+52
-6
lines changed

3 files changed

+52
-6
lines changed
 

‎docker.rst

+8-5
Original file line numberDiff line numberDiff line change
@@ -404,11 +404,14 @@ Inside the docker container, if there is a need to view any files, we have to in
404404

405405
**Console Log**
406406

407-
+-----------------------------------+--------------------------------------------------------+
408-
| ``docker logs -f container_name`` | prints out console log of a container in detached mode |
409-
+-----------------------------------+--------------------------------------------------------+
410-
411-
407+
Any console prints will be added to the docker log,
408+
and it will grow without a limit, unless you assigned one to it
409+
410+
+----------------------------------------------------------------------------------------------+--------------------------------------------------------+
411+
| ``docker logs -f container_name`` | prints out console log of a container in detached mode |
412+
+----------------------------------------------------------------------------------------------+--------------------------------------------------------+
413+
| ``docker run -d --log-opt max-size=5m --log-opt max-file=10 --name containername imagename`` | limit log file size to 5Mb and 10 log files |
414+
+----------------------------------------------------------------------------------------------+--------------------------------------------------------+
412415

413416

414417
Small Efficient Images

‎fastapi.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ We do the same for the request schema and place them in the routing function.
112112
import numpy as np
113113
114114
@app.post('/api', response_model= RESPONSE_SCHEMA)
115-
def human_detection(request: REQUEST_SCHEMA):
115+
async def human_detection(request: REQUEST_SCHEMA):
116116
117117
JScontent = json.loads(request.json())
118118
encodedImage = JScontent['requests'][0]['image']['content']

‎flask.rst

+43
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,23 @@ Here's one complete request with data
247247
--data '{"username":"xyz","password":"xyz"}' \
248248
http://localhost:5000/api
249249
250+
To run multiple requests in parallel for stress testing
251+
252+
.. code:: bash
253+
254+
curl --header "Content-Type: application/json" \
255+
--request POST \
256+
--data '{"username":"xyz","password":"xyz"}' \
257+
http://localhost:5000/api &
258+
curl --header "Content-Type: application/json" \
259+
--request POST \
260+
--data '{"username":"xyz","password":"xyz"}' \
261+
http://localhost:5000/api &
262+
curl --header "Content-Type: application/json" \
263+
--request POST \
264+
--data '{"username":"xyz","password":"xyz"}' \
265+
http://localhost:5000/api &
266+
wait
250267
251268
File Upload
252269
-----------
@@ -565,6 +582,32 @@ Apache's httpd.conf file.
565582
CMD /etc/mod_wsgi-express/apachectl start -D FOREGROUND
566583
567584
585+
Gunicorn is another popular, and extremely easy to use WSGI.
586+
We can just install as ``pip install gunicorn``.
587+
and start it with the simple command.
588+
589+
.. code::
590+
591+
# gunicorn -w 2 pythonScriptName:flaskAppName
592+
# it uses port 8000 by default, but we can change it
593+
gunicorn --bind 0.0.0.0:5000 -w 2 app:app
594+
595+
596+
``
597+
sudo apt-get install nginx
598+
# ubuntu firewall
599+
sudo ufw status
600+
sudo ufw enable
601+
sudo ufw nginx http
602+
sudo ufw status
603+
sudo ufw allow ssh
604+
605+
systemctl status nginx
606+
systemctl start nginx
607+
systemctl stop nginx
608+
systemctl restart nginx
609+
``
610+
568611

569612
* https://www.appdynamics.com/blog/engineering/a-performance-analysis-of-python-wsgi-servers-part-2/
570613

0 commit comments

Comments
 (0)
Please sign in to comment.