Open 2-click opened 2 months ago
Interesting. npm run start shows Express Manager as errored. npm run logs shows these lines:
/opt/loxberry/bin/plugins/logs/express-error.log last 15 lines:
1|Express | Require stack:
1|Express | - /opt/loxberry/bin/plugins/express/index.js
1|Express | at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
1|Express | at Hook._require.Module.require (/opt/loxberry/bin/plugins/express/node_modules/require-in-the-middle/index.js:61:29)
1|Express | at require (node:internal/modules/helpers:125:16)
1|Express | at Object.<anonymous> (/opt/loxberry/bin/plugins/express/index.js:13:16)
1|Express | at Module._compile (node:internal/modules/cjs/loader:1546:14)
1|Express | at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
1|Express | at Module.load (node:internal/modules/cjs/loader:1317:32)
1|Express | at Module._load (node:internal/modules/cjs/loader:1127:12)
1|Express | at Object.<anonymous> (/opt/loxberry/bin/plugins/express/node_modules/pm2/lib/ProcessContainerFork.js:33:23)
1|Express | at Module._compile (node:internal/modules/cjs/loader:1546:14) {
1|Express | code: 'MODULE_NOT_FOUND',
1|Express | requireStack: [ '/opt/loxberry/bin/plugins/express/index.js' ]
1|Express | }
I put a debug line in there and found out the path it tries to load:
const configFile = path.resolve(directories.config, 'express.json');
console.log('Resolved config file path:', configFile); // Debug line
const config = require(configFile);
loxberry@loxberry:~/bin/plugins/express $ cat /opt/loxberry/bin/plugins/config/express.json
cat: /opt/loxberry/bin/plugins/config/express.json: No such file or directory
Interesting! The path is wrong.
This is the correct path that exists: /opt/loxberry/config/plugins/express/express.json
This is the one it tries to load: /opt/loxberry/bin/plugins/config/express.json
With a debug statement I found out that lib/directories.js uses the debug environment and not the production environment. This could be due to me starting it with npm run or an actual bug.
Since this is no longer maintained I started my own plugin: https://github.com/2-click/loxberry-plugin-wifi-presence-unifi
Summary:
Plugin works after Installation. When device is rebooted, Plugin no longer works, gives this error message: Cannot load configuration. Try to restart the Server and reload the page.
Detailed issue:
After installing the Plugin, the express Server is running fine. We can confirm this by using the webinteface. With the PID we can also see the command that has been used to start the plugin:
After the reboot, the webinterface shows : Cannot load configuration. Try to restart the Server and reload the page.
Running the Server manually still works though
When Checking index.js we notice These lines:
We can reveal where that file is stored:
Permissions of the file:
-rw-r--r-- 1 loxberry loxberry 109 Aug 25 11:34 /opt/loxberry/config/plugins/express/express.json
Contents are{"expressPort":"3300","managerPort":"3301","loglevel":{"info":true,"debug":true,"warning":true,"error":true}}
Log files
No log files could be found under
/opt/loxberry/log/plugins/express
System information