hassio-addons/addon-node-red

Problems loading config #488

azafred posted onGitHub

Problem/Motivation

Post upgrade to 6.1.0 node-red is refusing to start with the following message:

[11:51:33] INFO: Starting Node-RED...

> addon-node-red@ start /opt
> node $NODE_OPTIONS node_modules/node-red/red.js "--settings" "/etc/node-red/config.js"

Error loading settings file: /etc/node-red/config.js
[11:51:34] INFO: Starting Node-RED...

> addon-node-red@ start /opt
> node $NODE_OPTIONS node_modules/node-red/red.js "--settings" "/etc/node-red/config.js"

Error loading settings file: /etc/node-red/config.js

I have been trying to start it by hand from the docker container, but alas, I can't seem to get any more information. I have checked that /etc/node-red/config.js and the reference file (/config/node-red/settings.js) are there and look good to me. However, js is not my forte ;p

Expected behavior

Node-red should start!

Actual behavior

Node-red doesn't start... The container starts, but not node-red itself:

Error loading settings file: /etc/node-red/config.js

Config file looks like:

const config = require('/config/node-red/settings.js');
const fs = require('fs');
const options = JSON.parse(fs.readFileSync('/data/options.json', 'utf8'));
const bcrypt = require('bcryptjs');

// Set dark theme if enabled
if (options.dark_mode) {
    config.editorTheme.page = {
        css: '/opt/node_modules/node-red-contrib-theme-midnight-red/midnight.css',
    };
}

// Sane and required defaults for the add-on
config.debugUseColors = false;
config.flowFile = 'flows.json';
config.nodesDir = '/config/node-red/nodes';
config.uiHost = '127.0.0.1';
config.uiPort = 46836;
config.userDir = '/config/node-red/';

//Set path for HTTP_Nodes to be served from avoiding lua auth
config.httpNodeRoot = '/endpoint';

// Disable authentication, let HA handle that
config.adminAuth = null;

// Disable SSL, since the add-on handles that
config.https = null;

// Several settings
config.credentialSecret = options.credential_secret;

// Secure HTTP node
if (options.http_node.username) {
    config.httpNodeAuth = {
        user: options.http_node.username,
        pass: bcrypt.hashSync(options.http_node.password),
    };
}

// Secure static HTTP
if (options.http_static.username) {
    config.httpStaticAuth = {
        user: options.http_static.username,
        pass: bcrypt.hashSync(options.http_static.password),
    }
}

// Set debug level
if (options.log_level) {
    config.logging.console.level = options.log_level.toLowerCase();
    if (config.logging.console.level === 'warning') {
        config.logging.console.level = 'warn';
    }
}

module.exports = config;

Steps to reproduce

Upgrade node-red from Hassio (home-assitant)


:wave: Thanks for opening your first issue here! If you're reporting a :bug: bug, please make sure you include steps to reproduce it. Also, logs, error messages and information about your hardware might be useful.

posted by addons-assistant[bot] about 5 years ago

I don't see anything that stands out, but there is an include for /config/node-red/settings.js, so I would validate that file.

posted by sinclairpaul about 5 years ago

It seems the problem is around bcryptjs. If I comment that line out as well as all the secure modes in the config, it starts up just fine. If I just uncomment Secure HTTP node and Secure static HTTP, it starts up with an error, obviously. If I leave const bcrypt = require('bcryptjs'); I get the error above.

I went ahead and apk add g++ followed by npm install bcryptjs, which installed the module just fine. (which I guess might mean it was not installed before?) but alas, that didnt help... still looking into it.

Cheers and thanks for the reply!

posted by azafred about 5 years ago

Can you post the first part of the add on log which shows your system details?

posted by sinclairpaul about 5 years ago

And your add on config, without any secrets.

posted by sinclairpaul about 5 years ago

sure thing:

[cont-init.d] 00-banner.sh: executing... 

-----------------------------------------------------------
 Add-on: Node-RED
 Flow-based programming for the Internet of Things
-----------------------------------------------------------
 Add-on version: 6.1.0
 You are running the latest version of this add-on.
 System: Arch Linux  (amd64 / qemux86-64)
 Home Assistant Core: 0.106.2
 Home Assistant Supervisor: 206
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------

Config is:

credential_secret: redacted
dark_mode: true
http_node:
  username: redacted
  password: redacted
http_static:
  username: redacted
  password: redacted
ssl: false
certfile: fullchain.pem
keyfile: privkey.pem
require_ssl: false
system_packages: []
npm_packages:
  - node-red-admin
  - node-red-contrib-google-home-notify
  - node-red-node-pushbullet
init_commands: []

I should note that with ssl turned off, node-red starts perfectly. It only has trouble when starting up with ssl enabled.

posted by azafred about 5 years ago

Just to confirm, this worked fine prior to upgrade with SSL enabled?

posted by sinclairpaul about 5 years ago

That is correct.

posted by azafred about 5 years ago

I'm facing the same issue. Any update on this?

posted by anurut about 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

posted by addons-assistant[bot] almost 5 years ago

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

posted by addons-assistant[bot] almost 5 years ago

Fund this Issue

$0.00
Funded

Pull requests