observer icon indicating copy to clipboard operation
observer copied to clipboard

Unable to load additional modules

Open dxdrew opened this issue 2 years ago • 9 comments

Hi,

I've got observer up and running under ubuntu 20.04, php7.4, nginx/1.14.0 and mariadb 15.1. I used the installation script to set up the environment and it all appears to work okay. I did have to backport gstreamer to get it to stream to icecast correctly.

However I'm unable to load any additional modules into observer.

To load install the modules I use the following steps. 1/ # git clone https://github.com/openbroadcaster/<module_name>.git /var/www/observer/modules/<module_name> 2/ # chown -R obsuser:obsuser /var/www/observer/modules/<module_name>

The observer UI fails to work once any new module is placed in the modules directory. Here is the error from the nginx err.log.

2022/03/14 11:26:25 [error] 23519#23519: *119 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Class 'statisticsModule' not found in /var/www/observer/models/modules_model.php:90 Stack trace: #0 /var/www/observer/classes/obfmodel.php(112) : eval()'d code(1): ModulesModel->get_all(true, false) #1 /var/www/observer/classes/obfmodel.php(112): eval() #2 /var/www/observer/models/modules_model.php(39): OBFModel->__invoke('get_all', true, false) #3 /var/www/observer/classes/obfmodel.php(112) : eval()'d code(1): ModulesModel->get_installed() #4 /var/www/observer/classes/obfmodel.php(112): eval() #5 /var/www/observer/classes/obfmodels.php(54): OBFModel->__invoke('get_installed') #6 /var/www/observer/models/ui_model.php(34): OBFModels->__call('modules', Array) #7 /var/www/observer/classes/obfload.php(174): UIModel->__construct() #8 /var/www/observer/classes/obfmodels.php(43): OBFLoad->model('ui') #9 /var/www/observer/index.php(40): OBFModels->__call('ui', Array) #10 {main} thrown in /var/www/observer/models/modules_model.php on line 90" while reading response header from upstream, client: <Client_IP>, server: <server.domain>, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "<Server_IP>"

Once I move the new module out of the modules directory, everything works again.

Is this a bug or am I doing something silly?

Thx in Advance.

dxdrew avatar Mar 14 '22 11:03 dxdrew

It turns out that the directory name for the module is incorrect when using git clone.

I my example I was trying to load the statistics module. "git clone" retrieved the code into a directory called "statistics".

To make the module work, I needed to rename the module directory to align with the class definition of the module which is in the first few lines of the module.php file. The trick is to remove the capitalisation, insert an underscore between the words, and exclude the word "Module" at the end.

So in my example loading the statistics module, the class information is:- class DataAndStatisticsModule extends OBFModule

the directory name should be:- data_and_statistics

Hope this helps others.

Thanks to markb for the help

dxdrew avatar Jun 13 '22 14:06 dxdrew

Thanks for the report of the module issue and workaround. A while back, we organized our repos and renamed many of the modules before making them public. This is probably where the mismatch occurred and most likely affects other modules that were renamed. Perhaps @vincentthedev can run a script to check all modules for this issue so the directory name matches module name?

radiorob avatar Jun 15 '22 17:06 radiorob

The best thing today since Brook told me the folder should match the class name is to rename all of the repo's to match.

vincentthedev avatar Jun 15 '22 17:06 vincentthedev

Part of the organization of the module names was to make them shorter and less complicated so their respective GH-Pages rendered to our main support pages, cleaner TOC. An example is https://support.openbroadcaster.com/statistics/

radiorob avatar Jun 15 '22 17:06 radiorob

Yes but users would need to clone them with the proper path by hand. I think we should include examples of the right clone command in the read me file if you want to keep the structure the same. I can add them to read me if you think it's a good idea.

vincentthedev avatar Jun 15 '22 19:06 vincentthedev

Hi guys! As the 'markb' who initially helped fix this issue, is there a possibility of working to change the module loading mechanism itself? It seems to me that where it assigns the $module_class_name variable could be refactored to read a manifest file, or some other (non directory-dependent) source, so that users can load modules more intiutively? $module_class_name = $dir.'Module'; I'm happy to have a look at this issue and create a PR with a potential fix. Of course, there is the backward compatability issue of requiring an extra bit of info for the module, but I think it would improve the user experience greatly -- let me know your thoughts!

Xenarc avatar Jun 19 '22 05:06 Xenarc

Thanks @Xenarc for providing feedback and the folks in radio AU that caught this. We can leave the names of the repos as they are and include a file with example config instructions on Statistics module. We have a GH-pages Index.md that renders to support.openbroadcaster.com page for each module. On the main repo we already have a README (essentially a description) We can include the example and instructions here or what about an INSTALL.md or INSTALL.TXT? Where ever we do this, we'll indicate this is a temporary work around and will get a wholistic refresh of all the modules and how to get them running and updated more effiefently. Where I envision being able to add them through our main uploader, being able to remove them this way (and the dirs it creates) and set the dirs\permissions that way with a manifest or .info file. This would require a bit of coding in the systems uploader mechanism to recognize system type "modules" in the media library to safely allow them in after vetting through the junk filters.

radiorob avatar Jun 28 '22 22:06 radiorob

Thanks @radiorob, those are some great suggestions. I definitely think here would be a good place to communicate the temporary work-around, maybe even in the modules' respective readme.md too (or a link to centralised, module-agnostic install instructions).

Xenarc avatar Jul 02 '22 01:07 Xenarc

Marking as bug/enhancement - repo names should match required module directory name, and/or appropriate documentation needed, and/or error message if mismatch (possibly in ob cli check).

brookgagnon avatar Nov 12 '22 17:11 brookgagnon