- Platform information: Synology
- Hardware: CPUArchitecture/RAM/storage
- OS: what OS is used and which version
- Java Runtime Environment: which java platform is used and what version
- openHAB version: 3
- Issue of the topic: please be detailed explaining your issue
I’m running Openhab 3 in a docker container on a Synology NAS. I’m trying to call a node.js script from Openhab:
executeCommandLine(Duration.ofSeconds(20), “node”, “/openhab/conf/scripts/test.js”)
The log is saying: [WARN ] [rg.openhab.core.io.net.exec.ExecUtil] - Failed to execute commandLine ‘[node, /openhab/conf/scripts/test.js]’
The owner of the file is set to 9001:9001 which is the openhab user/group. The script is working when I ssh into the host machine. So I guess docker may be the problem. Normal bash scripts can be called from Openhab. I’ve tried everything that came to my mind for hours and I’m out of options now. Any idea? Could it simply be that node is not available in the container? If so, I have no idea how to install it. Thank you for help.
Always look to see if it has anything else to tell you
val results = executeCommandLine(Duration.ofSeconds(20), "node", "/openhab/conf/scripts/test.js")
logInfo("myexec", "results " results)
2022-02-08 10:03:57.526 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘49065d66d9’ failed: val results = executeCommandLine(Duration.ofSeconds(20), “node”, “/openhab/conf/scripts/test.js”)
logInfo(“myexec”, "results " results)
Oh, I missed a plus out. It pays to read what you copy-paste.
logInfo("myexec", "results " + results)
You’ll need to be careful about quotemarks when copy-pasting from this forum too.
Yes, of course node is not available in the container. The main point of a container is to contain just enough to run the one service. openHAB doesn’t require node so node isn’t installed. Neither is Python nor SSH, nor X nor a whole host of other stuff. In fact, for a long time even
ping wasn’t installed.
The proper Docker answer would be that you shouldn’t install node into the container. You should set up a separate container with a node service that openHAB calls via some API (e.g. MQTT, REST HTTP call, etc.). The whole point of Docker is to isolate all the services from each other. When you put it all in one container, you’ve lost the flexibility Docker offers and you may as well just run on bare metal or a VM.
But that’s not always practical. So you have two options: