From d20d59249562d5420a6d1534c819254a1d50df91 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Thu, 4 Nov 2021 19:39:12 +0000 Subject: [PATCH] update Midpoint doc. --- midpoint/rtr-midpoint.md | 62 +++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 16 deletions(-) diff --git a/midpoint/rtr-midpoint.md b/midpoint/rtr-midpoint.md index aaafc82..81a1210 100644 --- a/midpoint/rtr-midpoint.md +++ b/midpoint/rtr-midpoint.md @@ -108,8 +108,7 @@ After you have established a V.M. on A.W.S. or your own server, you will need to clone the repository (**I am assuming this is via SSH**). ```bash -# Adjust the directories to how you prefer it. These are just my -defaults. +# Adjust the directories to how you prefer it. These are just my defaults. mkdir www cd www git clone http://git.abbether.net/return-to-ritherdon/midpoint.git @@ -163,10 +162,11 @@ the 'connext_app' related to the use of the Swagger API code. gunicorn -w 3 server:connex_app ``` -The -w 3 bit refers to the total number of workers (processors) +The `-w 3` bit refers to the total number of workers (processors) Gunicorn will use whilst running. The general rule to work that out it -/(number of processors * 2) + 1. At the time of writing, the V.M. is a -very basic one-core machine so that is why three workers is used. +/(number of processors * 2) + 1. At the time of writing, the virtual +machine used for the exhibition is a very basic one-core machine so +that is why three workers is used. One problem with Gunicorn is it blocks the terminal when using it in its default way. To get around this, I have install Supervisor to @@ -179,19 +179,21 @@ sudo apt install supervisor ``` When Supervisor is installed, you need to create a config. file. The -file for this project is stored at -`/etc/supervisor/conf.d/spiapi.conf`. The log files (specified in the -.conf) file are, +file for this project is stored at, + +- `/etc/supervisor/conf.d/spiapi.conf` + +The log files (specified in the .conf) file are, - `/var/log/midpoint/midpoint.err.log` - `/var/log/midpoint/midpoint.out.log` -You will to recreate the directory they are stored in if you are -installing this site to a new system. The easiest way to do that is to +You will need to recreate the directory they are stored in if you are +installing this site on a new system. The easiest way to do that is to run the following command, ```bash -sudo mkdir -p /var/log/roaming-light-api +sudo mkdir -p /var/log/midpoint sudo touch /var/log/midpoint/midpoint.err.log sudo touch /var/log/midpoint/midpoint.out.log ``` @@ -206,12 +208,14 @@ sudo supervisor reload It might take a little while for the service to restart so if you still see "Bad Gateway" messages in the browser, that might be why. -You might find Gunicorn is not installed in the virtual-environment, -it that is the case, you should find it at, +You might find Gunicorn is not installed in the virtual-environment +(if you have decided to not install one or you simply forget to +activate like I have a habit of doing), it that is the case, you +should find it at, - `home/ubuntu.local/bin/gunicorn` -This might, also, mean you need to use apt and not pip3. +This might, also, mean you need to use `apt` and not `pip3`. The config. file for Supervisor should look something like the following, (remember to adjust the places where `ubuntu` is with your @@ -252,11 +256,12 @@ username. ### Flask & Swagger To access the A.P.I. user-interface (via Swagger), enter -`http://0.0.0.0:5000/api/ui/`. + +-`http://0.0.0.0:5000/api/ui/` - [Real Python](https://realpython.com/flask-connexion-rest-api/#using-connexion-to-add-a-rest-api-endpoint) -This site provides a good walk-through for setting-up a website using +Real Python provides a good walk-through for setting-up a website using the Flask framework. Real Python, also, provides guides on creating websites with Python and its various website frameworks. @@ -287,8 +292,33 @@ database. To do that, you will need to run the following commands, # match your set-up. cd ~/www/midpoint/app/ +# If you have created and activated a virtual environment, you can +# enter 'python' instead of 'python3'. python3 build-database.py ``` This will clear the database if one is already set-up and then build a new one. + +## Notes on System Limitations + +### 1. Connection Times-Out on Large JSON Packets + +The biggest thing to remember the REST API calls which grab 'all' the +light readings from every device, will start to fail fairly quickly +after a 'clean install'. The reason why is because the JSON package +becomes too large and the connection times out. You might get better +results on a more powerfully spec'd server than the one used for the +exhibition but I have not tested this so I cannot confirm this. + +### 2. Three Light-Meters and Relays Specified but Only Two (of each) Used + +Ritherdon (the factory) has three welding booths so 'Personal Flash in +Real-Time' was designed with this in mind. Over the course of the +development process, the use of the third booth was not +needed/wanted. By that time, the code, database and models had already +been created. I decided to opt for the lazy option and keep the +references to the third booth instead of removing it because it was +not impeding on the system in any way. I was, also, cautious about the +chance of a change happening late into the development cycle were I +would need to put it back it.