5G-MAG / rt-5gms-application-server

5G Media Streaming - Application Server
https://www.5g-mag.com/streaming
Other
4 stars 5 forks source link

Bug fixes: Find mime.types file location and automatically find Openresty path #90

Closed davidjwbbc closed 2 weeks ago

davidjwbbc commented 4 weeks ago

This PR includes some minor bug fixes for #83 and #89.

Find mime.types file (#83):

Automatically find Openresty path (#89):

Fixes #83 Fixes #89

davidjwbbc commented 3 weeks ago

Changes look good, @davidjwbbc .

In addition, would it be possible to print out some informative lines to the console to confirm which paths have been detected for the binary and modules? This is then valuable feedback for the user to understand what's going on when there are multiple instances installed at different paths.

Added log output to log INFO messages about the path and mime.types file location. For example:

INFO:rt-5gms-as:Found OpenResty path at /usr/local/openresty/nginx/sbin, will try this path first for nginx executable location
INFO:NginxWebProxy:Found mime.types file at /usr/local/openresty/nginx/conf/mime.types
[2024-06-11 11:52:21 +0100] [10512] [INFO] Running on http://127.0.0.1:7777 (CTRL + C to quit)
INFO:hypercorn.error:Running on http://127.0.0.1:7777 (CTRL + C to quit)
jordijoangimenez commented 3 weeks ago

Hi David, I've reinstalled from your branch and I keep getting the lua_package_path error:


fivegmag@5GMAG-NUC:~/rt-5gms-application-server$ sudo 5gms-application-server
INFO:NginxWebProxy:Found mime.types file at /etc/nginx/mime.types
[2024-06-14 11:22:04 +0200] [3394050] [INFO] Running on http://127.0.0.1:7777 (CTRL + C to quit)
INFO:hypercorn.error:Running on http://127.0.0.1:7777 (CTRL + C to quit)
INFO:NginxWebProxy:
ERROR:NginxWebProxy:nginx: [emerg] unknown directive "lua_package_path" in /tmp/rt_5gms_as.conf:48

INFO:rt-5gms-as:Web proxy process exited, has been restarted
INFO:NginxWebProxy:
ERROR:NginxWebProxy:nginx: [emerg] unknown directive "lua_package_path" in /tmp/rt_5gms_as.conf:48

INFO:rt-5gms-as:Web proxy process exited, has been restarted
INFO:NginxWebProxy:
ERROR:NginxWebProxy:nginx: [emerg] unknown directive "lua_package_path" in /tmp/rt_5gms_as.conf:48

INFO:rt-5gms-as:Web proxy process exited, has been restarted
INFO:NginxWebProxy:
ERROR:NginxWebProxy:nginx: [emerg] unknown directive "lua_package_path" in /tmp/rt_5gms_as.conf:48

INFO:rt-5gms-as:Web proxy process exited, has been restarted
INFO:NginxWebProxy:
ERROR:NginxWebProxy:nginx: [emerg] unknown directive "lua_package_path" in /tmp/rt_5gms_as.conf:48

INFO:rt-5gms-as:Web proxy process exited, has been restarted
INFO:NginxWebProxy:
ERROR:NginxWebProxy:nginx: [emerg] unknown directive "lua_package_path" in /tmp/rt_5gms_as.conf:48

ERROR:rt-5gms-as:nginx web proxy restarting too quickly, aborting...
``
jordijoangimenez commented 3 weeks ago

I believe it is useful that when doing a clean installation I make sure Openresty is installed... IGNORE the above. It works, now trying to disable nginx:


fivegmag@5GMAG-NUC:~/rt-5gms-application-server$ sudo 5gms-application-server
INFO:rt-5gms-as:Found OpenResty path at /usr/local/openresty/nginx/sbin, will try this path first for nginx executable location
INFO:NginxWebProxy:Found mime.types file at /usr/local/openresty/nginx/conf/mime.types
[2024-06-14 11:33:51 +0200] [3412561] [INFO] Running on http://127.0.0.1:7777 (CTRL + C to quit)
INFO:hypercorn.error:Running on http://127.0.0.1:7777 (CTRL + C to quit)
INFO:NginxWebProxy:
ERROR:NginxWebProxy:nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
``
jordijoangimenez commented 3 weeks ago

@davidjwbbc, after testing, I think we are good to go. My recollection on the instructions will be that the export PATH command is no longer needed and that systemctl disable --now nginx.service openresty.service is still needed before execuding 5gms-application-server to avoid active instances

jordijoangimenez commented 3 weeks ago

I would suggest to move the installation of Openresty upwards and make it a more explicit step. I would integrate the paragraph

Please note that the application server requires a suitable web proxy server to be installed. At present the only web proxy server that the application server can use is Openresty. This means you should install the openresty package on your distribution, instruction to do so can be found on the Openresty website for linux distributions and Microsoft Windows. The Openresty version of nginx should also be the first version on the system path.

within "Install dependencies" rather than under running (you will try to execute 5gms-application-server but the paragraph telling you to install openresty just comes next).

davidjwbbc commented 3 weeks ago

Ok, I've improved the OpenResty executable finding by verifying the nginx executable found was compiled to handle LUA.

If no suitable executable is found then the following error is displayed:

ERROR:rt-5gms-as:Please install at least one of: openresty

"openresty" being the only web proxy module currently implemented (renamed from "nginx" to avoid confusion). If more web proxy modules are added and none find their executables are found then they are all listed here.

If the openresty web proxy module found a suitable nginx executable then it is reported:

INFO:OpenRestyWebProxy:Found nginx executable supporting LUA at /usr/local/openresty/nginx/sbin/nginx

Note: I'm no longer adding the known openresty path to the PATH environment variable, instead the openresty web proxy module provides the known openresty path as an extra path to try to the function which finds executables. This allows the AS to be run with an alternative OpenResty in the PATH to use that one instead.

jordijoangimenez commented 3 weeks ago

@davidjwbbc same as Richard. I cannot find the line in the app.py file of the PR. I see the correction if I go directly to your branch though. Somehow the PR is not up to date?

jordijoangimenez commented 3 weeks ago

sorry, I see it now. Line 261 but somehow the change is not displayed by GitHub under "Files changed". I think this is good to go.