-
Notifications
You must be signed in to change notification settings - Fork 0
Implement support for webqueue2 on templeton #162
Comments
I have a successful proof of concept for using The modules needed for this include:
I can confirm that those modules are present by checking the loaded modules with
With these modules loaded, I can use create a
For example, if I wanted to host the webqueue2 from https://engineering.purdue.edu/webqueue/q2 I would create the file
At this point, the directory structures looks like this:
Assuming the But if I request a valid API endpoint, like the item CE 100, I would see something like: With this solution in place, it would be possible to host the webqueue2 frontend as one server on Templeton and host the API as another serve on Templeton with the reverse proxy pointing to the API server. This has the benefit of no further modification to the API and a draw back of needing an automatable mechanism to start, stop and restart the API. Further research needs to be done to see how running the API as a CGI script affects it. |
Using the Flask CGI handler I am able to run the API as a CGI with very little changes. By combining the reverse proxy abilities previously mentioned and adding Assuming I wanted to serve webqueue2 from https://engineering.purdue.edu/webqueue/q2 which corresponds to
Now I need to create a Python virtual environment for the API to run from by running:
This will create the # Activate the Python virtual environment
source venv/bin/activate
# Update to the latest version of pip
pip install --upgrade pip
# Install the project dependencies
pip install -r requirements.txt
# Deactive the Python virtual environment
deactivate Now with a virtual environment and the needed Python packages, I can modify the API module # api.py
...
from wsgiref.handlers import CGIHandler
...
if __name__ == "__main__":
CGIHandler().run(app) After this I change the name of the API module from mv api.py apy.cgi With the API prepared to run as a CGI script and the the virtual environment created, I can use an
At this point the directory structure looks like this:
I have some questions about this setup that need to be tested moving forward:
|
An initial test of loading both the frontend and the backend with the previously mentioned
|
Another consideration to keep in mind is that once the routing changes in the frontend and CGI modifications for the backend are made, the development environments of w2vm[1-5] will need to be modified to allow for testing with similar configurations to templeton. |
In response to the previously asked question:
When measuring the time difference between running the API as a CGI script vs. WSGI application I found:
Tests were run by loading a page for the API as a CGI script and a page for the API as a WSGI application then defining timing functions in the browser's developer tools. These timing functions measure the time from making a call to the API to resolving the resultant JSON. (For simplicity, JWT authorization was temporarily disabled.) The timing functions were run 5 times in quick succession and the times were averaged before being compared. Below are the timing functions run. Note that the path used in the fetch call differed between the CGI and WSGI tests because of environmental differences but should not affect the execution time: let timedQueueResolve = async () => {
let start = performance.now();
let ceQueue = await fetch("/api/ce");
let ceQueueJson = await ceQueue.json();
let end = performance.now();
console.log(`Fetching the CE queue took about ${(end - start)/1000} seconds.`);
}
let timedItemResolve = async () => {
let start = performance.now();
let ceQueue = await fetch("/api/ce/1");
let ceQueueJson = await ceQueue.json();
let end = performance.now();
console.log(`Fetching CE 1 item took about ${(end - start)/1000} seconds.`);
} The results were as follows:
|
In response to the previously asked question:
It appears that this issue was caused when the rewrite rule from the
|
Talked to @sundeep proposing the API be run as a separate web entity which reverse proxies API requests to the WSGI server when requests are made to the webqueue2 frontend. He signed off on that. I need to get this running to show @cs that it can work with a cron job and an init script but no larger changes to management tools or established process. |
Previously I had thought that the EasyAD library required I'd attempted to install EasyAD within a virtual environment on one of the development machines before without success and instead of reading through the error message I assumed it was a lack of Knowing that OpenLDAP was already installed on templeton, I assumed that these header files were installed and tried to run the existing EasyAD implementation directly on templeton. It worked! In short, Curtis was right that we do not need See also: Customizing the Install of PyLDAP |
Curtis responded to my request for the OpenLDAP dev files to be installed on webqueue2 development machines saying those were already there. He was right as shown below:
While trying to reproduce the BER encoder/decoder error I found that I had been experimenting on Pier -- not the webqueue2 development machines. After attempting to install
Knowing that
wget https://github.com/python-ldap/python-ldap/archive/python-ldap-3.3.1.zip unzip python-ldap-3.3.1.zip # Remove the archive.
rm python-ldap-3.3.1.zip # Enter the source code directory.
cd python-ldap-python-ldap-3.3.1/
nano setup.cfg
Note: Simply omitting the
python3 -m venv __venv__ source __venv__/bin/activate
python setup.py build python setup.py install
pip install --upgrade pip pip install easyad At this point I copied the Active Directory auth code and tested it with success. I'll need to automate the building of |
Building of |
For this issue to be closed the following issues need resolved in this order: |
Following a conversation with @sundeep , @cs and I today, some architectural changes will need to be made to webqueue2.
A core reason for rewriting webqueue2 is to address accumulated technical debt and produce a system that meets today's needs. This is in conflict with current state of ECN's web hosting infrastructure on templeton. While webqueue2 has a WSGI based API server, templeton only has the ability to support serving static files and CGI scripts. While addressing technical debt and adding features to meet today's needs is a leading reason behind webqueue2, in order to move forward support for CGI based API interaction will need to be added.
This appears to be possible at the cost of performance and system resources. At its core, the webqueue2 API works via Python Flask which supports running as a CGI application according to the project's documentation. This would allow us to run the API within the constraints of templeton but there still needs to be a proxy from the Apache instance to the API.
The proxy may be possible via a rewrite rule using
.htaccess
files. These files can control the Apache config per directory and the rewrite engine can act as a proxy to a local port. This would require mod_rewrite to be enabled and while it isn't loaded with the current configuration, it is listed as a loadable module. I need to check with @cs about loading mod_rewrite.More testing is needed but this may prove to be the best option available.
The text was updated successfully, but these errors were encountered: