Problem with autostarting EspruinoHub.service

Posted on
  • Hello

    I trying to get the EspruinoHub.service to autostart by following the instructions on the Github page. But when i run the command I get this:

    pi@hassbian:~ $ sudo systemctl start EspruinoHub.service && sudo journalctl -f -u EspruinoHub
    -- Logs begin at Mon 2017-06-19 12:54:56 CEST. --
    Jun 20 21:44:44 hassbian EspruinoHub[23931]: readlink: missing operand
    Jun 20 21:44:44 hassbian EspruinoHub[23931]: Try 'readlink --help' for more information.
    Jun 20 21:44:44 hassbian sudo[23938]: pi : TTY=unknown ; PWD=/home/pi/EspruinoHub ; USER=root ; COMMAND=/s                                                                       bin/setcap cap_net_raw+eip
    Jun 20 21:44:44 hassbian sudo[23938]: pam_unix(sudo:session): session opened for user root by (uid=0)
    Jun 20 21:44:44 hassbian EspruinoHub[23931]: usage: setcap [-q] [-v] (-r|-|<caps>) <filename> [ ... (-r|-|                                                                       <capsN>) <filenameN> ]
    Jun 20 21:44:44 hassbian EspruinoHub[23931]: Note <filename> must be a regular (non-symlink) file.
    Jun 20 21:44:44 hassbian sudo[23938]: pam_unix(sudo:session): session closed for user root
    Jun 20 21:44:44 hassbian EspruinoHub[23931]: /home/pi/EspruinoHub/ line 9: node: command not foun                                                                       d
    Jun 20 21:44:44 hassbian systemd[1]: EspruinoHub.service: main process exited, code=exited, status=127/n/a
    Jun 20 21:44:44 hassbian systemd[1]: Unit EspruinoHub.service entered failed state.

    I can run the file normally by


    and everyhting works as promised but I just can't get the systemdb to work.
    Any ideas?

    Edit: EspruinoHub is installed in /home/pi/EspruinoHub.

  • @tom.gidden do you have any ideas about this? (Tom originally added the code for running the hub as a service - personally I still tend to run it so the Pi boots up and displays it on the screen)

  • I should say that I had to modify the installation process a bit because the node-red installation script didn't work because the command: sudo npm, didn't work. So I had to install it with:

    npm install -g node-red

    and then use pm2 to autostart node-red because the "node-red-start" service didn't work either, probably because of the installation path.
    Linux makes me mad sometimes.

  • That's odd - what did sudo npm say?

    It definitely works on the Pi I have here, but I haven't updated the OS in a month or two. Things get changed all the time and it's a constant battle to keep documentation up to date :(

  • Hi,
    Well, from the error log it looks like this line of the script is failing:

    sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)

    readlink isn't getting a parameter, and so is returning nothing; and so setcap is missing that parameter too. The most likely answer to this is that which node is failing, ie. node can't be found.

    Since you say run manually is working, I'd say that it's not that node (and npm, since you're having trouble with that too) isn't installed at all, but that it's not in the path for the user under which node-red is being run. That'd imply a slightly non-standard installation of Node, at least as far as the assumptions of this script are concerned (...or perhaps we've been using a non-standard Node!)

    Did you start with a Raspbian that has Node and Node-RED preinstalled? If not, I'd start by redoing the installation of Node. If so, maybe there's a problem with our script and that should be a little more aggressive about finding it, rather than just assuming it's in $PATH.

    Please can you try:
    which node
    whereis node
    nave ls (might fail)

  • Thanks! Just a thought but you could try installing the nodejs-legacy package? I seem to remember on some OSes you need that as the default node.js executable changed name to node.js?

  • In later it is installed as nodejs and there is package that does a symbolic link to node - the legacy one you mention.

  • Hmm. Okay, I'll try to take a look at this when I next get a chance, if no-one else gets there first: a fresh install of Raspbian without my usual install.

  • Thanks for the explanation @tom.gidden and you perfectly correct, my nodejs installation is non-standard.
    My base is Hassbian (Rasbian with Home Assistant and some other stuff thrown in), but then I used "n-installer" to install the latest version of node and the path to Node and NPM is some thing like "home/pi/n/...", can't check it exackly right now.
    The reason for doing it like that? Well mostly because Google told me it was an easy way I think and I needed a newer version of node then the one pre-installed. I didn't install Nodejs for Node-Red but for a bridge between smartthings and Home Assistant.

    I going to try to have PM2 start EspruinoHub instead, as I do with Node-Red right now, but if I can't get that to work I guess I have to remove and reinstall node, npm and node-red!

  • If I remember correctly, Node-RED actually needs an old version of Node at the moment.. well, not older as such, but I think it only runs on Node 6.x (the long-term stable release), rather than the state-of-the-art Node 7.x. As a result, it doesn't support Promises and a host of other ES6 features.

    One option is to use nave, which lets you have several versions of Node installed and switch between them as needed. That way, you can have Node-RED and EspruinoHub running in Node 6.x, and use another version for other scripts. Or, as you say, just reinstall with Node 6.x: most code should work with it.

    My version of EspruinoHub.service is substantially different as I don't use standard Node either: I install the base server version of Raspbian and do a custom install of Node into its own user.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Problem with autostarting EspruinoHub.service

Posted by Avatar for Trisk3lion @Trisk3lion