Node-red on ubuntu - dumb question

#1

Hi.

Sorry, but I am stuck on this (latest) problem:
I got a new machine the other day and want to get NR working on it.

That shouldn't be a problem because I already have it working on THIS machine which is also running Ubuntu.

Usually I run a command to install it, but as I discovered that is for the RPI and can't be used on an x86 machine as opposed to the ARM of the RPI.

Where I am falling over is getting NR to auto start.

Usually it is:
sudo systemctl enable nodered.service

But when I do that, it says there is no such service, or the service can't be found.
(Not on that machine at the moment.)

If I - from the CLI - enter node-red, it works.
Which is fair enough. But that doesn't help get it going when the machine boots.

Anyone - please.

0 Likes

#2

There's a whole section of the documentation that deals with running node-red as a service on probably half a dozen OS types... are those instructions not working or incomplete?

1 Like

#3

When I looked there I "missed?" the INSTALLATION part.

All I saw was making your first flow, and so on.

Well, that was a lot of fun.

It just skims over what I already know.

At the end is only does what I have already done.
Running

Further down it has this:

Adding Autostart capability using SystemD

Yeah, but all the words are for the RPI. Example:

raspbian-deb-package

Then it gets to:

sudo systemctl enable nodered.service

Which is where I am/was at.

sudo systemctl enable nodered.service
Failed to enable unit: Unit file nodered.service does not exist.

So I am still stuck.

I shall again state that I am finding instructions written for people who ALREADY KNOW THE ANSWER and only need to have the information refreshed.

Not for people like me. Be that makes me what ever.

I appreciate the reply but I seem to now be detecting sarcasm in it, more than help.

0 Likes

#4

The running node red at start instructions say

Linux users that have a Debian flavour (e.g. Ubuntu, Mint, Debian, etc) are recommended to use the Adding Autostart capability using SystemD instructions from the Raspberry Pi docs though you will need to edit the downloaded /lib/systemd/system/nodered.service file to suit your user id and environment.

So yes you need to follow the pi instructions, especially the bit where it tells you the commands to type. BUT you must also edit the file mentioned above... I.E. change the user from "pi" to whatever your user on Ubuntu is called. This is also documented in the paragraph below the adding autostart section.

0 Likes

#5

I am not home just now but in reading what you say:

It begs the question that if NR can install itself on the RPI to the point that when you do the "systemctl enable node red. service" and it works yet can't do that on Ubuntu which is very close to the RPI O/S and people like me miss that, blaming them doesn't help their confidence to want to TRT and learn.

It isn't like I am trying to do it on Windows or the Mac o/s.

Just saying.

Gotta go to deal with what is happening now - (life in general)

0 Likes

#6

I think the issue is that not all the distros have moved to SystemD yet therefore there are many edge uses cases that would need to be catered.

The hint is in there - here is mine for instance that was built from Peter Scargills script (when i was just starting out with NR on a VM)

systemd service file to start Node-RED

[Unit]
Description=Node-RED graphical event wiring tool
Wants=network.target
Documentation=http://nodered.org/docs/hardware/raspberrypi.html

[Service]
Type=simple

Run as normal pi user - feel free to change...

User=pi
Group=pi
WorkingDirectory=/home/pi
Nice=5
Environment="PI_NODE_OPTIONS=--max_old_space_size=256"

uncomment and edit next line if you need an http proxy

#Environment="HTTP_PROXY=my.httpproxy.server.address"

uncomment the next line for a more verbose log output

#Environment="NODE_RED_OPTIONS=-v"
#ExecStart=/usr/bin/env node $PI_NODE_OPTIONS red.js $NODE_RED_OPTIONS
ExecStart=/usr/bin/env node-red-pi $PI_NODE_OPTIONS $NODE_RED_OPTIONS

Use SIGINT to stop

KillSignal=SIGINT

Auto restart on crash

Restart=on-failure

Tag things in the log

SyslogIdentifier=Node-RED
#StandardOutput=syslog

[Install]
WantedBy=multi-user.target

Craig

0 Likes

#7

As much as I would like to say I am happy, I am still not getting it all.

Half the stuff is Ubuntu and the other half is Ras-Pi stuff.

I get that if I am using a RPI I need the lines in. But if I am not using a RPI, then I would guess that those lines are not needed.

What ever.

I shall continue trying to work out where I am wrong. I don't want to waste anyone else's time.

It isn't the end of the world, but it is ..... (ah, doesn't matter.)
I kinda give up.

0 Likes

#8

That is the point of what i have given you - it is running on an Ubuntu 16.04LTS VM

Drop it in and away you go.

Everyone in these sorts of projects has limited resources - they target a popular platform and concentrate on it and do their best to make the environment (support/doco etc) work for that configuration. This is somewhat easier with SBCs as there are very few things that can change - other than new models of board being released.

When you move to a general purpose OS on a PC platform the number of permutations becomes horrific and they end up holding peoples hands through Operating system basics as well as OS support before they even get to running their application.

The assumption they make is that if you are not going to go for the most widely used and supported platform (which also happens to be bloody cost effective) that you wil lhave to do a fair bit of the learning yourself - that will lnot necessarily be from first principles, but through the internet and directed questions.

Nick has put out a call for more helpers - not just in coding but also in doco, wiki etc etc - possibly an avenue to get involved once you are an expert on VMs and NR installs !

Craig

0 Likes

#9

Thanks. I may, but looking at how "good" (cough) I am at that, I think I would be more a hindrance than help.

And I am sure that confusing an already complicated area is not going to do any good for anyone.

Back to working on the problem - for me.

0 Likes

#10

But the point is - you could write the doco from an absolute beginners point of view (which is what you are complaining about that the doco does not cover)

You can never have too much doco and if there is an absolute newbie section for this permutation you would be set.

The lines i posted are my whole file for starting the node-red service - the only thing they assume is that you

1)Have installed as user pi
2) have a home directory /home/pi that you are using and that the user pi has control of

Craig

0 Likes

#11

You could have also just used Peter Scargills install script (he has one that he has developed to run under Ubuntu/Xenial) that would do all this for you as well as get a lot of good nodes etc

Craig

0 Likes

#12

I guess that last post could be true.

But I am not having much luck with the VM part of things at this point.

I spent 3 hours installing Ubuntu on the new machine yesterday because I couldn't find the Ubuntu install disc, and the NUC won't boot of USB. (Grrrr!) and so when I installed it the first time and updated it and then UPDATED it..... Then installed NR and stuffed it up so badly I just had to go back and start anew.

I am a day behind the time line because of that and am trying to get caught up before Friday so I can close this week's tasks off as done and not "still pending", which I don't like doing all the time.

What you are saying is good in theory.
But it presumes:
I know how to use the VM very well.
I can (well. I've found the DVD now) find the Ubuntu DVD at a whim.
Nothing goes wrong with the install of the O/S and the install of NR.

There's a lot of IFs in there and just now I don't need them. I need things that are certain.
Alas even so, there are still a lot of ...... certainty in what I have now.

0 Likes

#13

The bash curl script for the pi works perfectly well on Ubuntu, at least it does for me.

Colin

0 Likes

#14

Nope - you are jumping too many steps ahead.

If you do not want to do it as a VM then do a plain vanilla install of Ubuntu 18.04 LTS

Run all updates etc.

Then go to Peter Scargills site - get the latest version of the script - read the readme and run it.

It will pull down NR, etc etc

Some of which will be out of date - but will give you a known working config.

Craig

0 Likes

#15

You have an issue with your NUC if you can not get it to boot off USB - i would more suggest it is to do with how you are creating your USB key or the quality of the USB key

I use RUFUS to create most of my USB keys and have very little issues with it

THere is a security setting in the BIOS on NUCs to disable USB booting - potentially you have enabled that

Craig

0 Likes

#16

Colin,

I can't and won't dispute that.

But what is driving me nuts is that in the configuration of things like user name, and home directory I fully get that these things are UNIQUE to every machine and user.
Save that everyone calls themselves "pi". I do, but the passwords are killers.

Anyway, fair enough.

But (I will have to use analogies here now because I want to show how confusing it is for me) it seems "silly" (?) that I am reading the instructions on how to use a FORD car, and yet HOLDEN is mentioned throughout the instructions.

Why are there lines which are for the RPI needed in the general configuration if I am running it on another machine?
eg: Why say the HOLDEN MOTOR when discussing a FORD?

Node-Red is stratified from the OS, so I am using Ubuntu on a (cringe) intel NUC.
NOTHING to do with RPI.

Yet!

I MUST HAVE lines in the config which are specifically Raspberry Pi:
example:

ExecStart=/usr/bin/env node-red-pi $PI_NODE_OPTIONS $NODE_RED_OPTIONS
Environment="PI_NODE_OPTIONS=--max_old_space_size=256"
Documentation=http://nodered.org/docs/hardware/raspberrypi.html

Ok, the last one I can let slip.

But! Unless PI_NODE_OPTIONS means something else than implicitly RASPBERRYPI why call it PI?

0 Likes

#17

To answer that specific point - that is a variable name inside the script. What it does is limit the amount of memory node.js uses when running Node-RED to try to stop the machine crashing. As the Pi only has a small amount of memory we try to limit it. This would apply to any small-ish device (with less than 2GB ram).

So while it is not 100% specific to PI - it is really aimed at smaller devices like Pi. But hey - I will remove the word PI_ from the variable name if it would un-confuse you :slight_smile:

0 Likes

#18

DC,

Sorry it isn't that I was directing at you in a bad way.

I was only wanting to point out HOW I got confused.

Maybe leave it as is, but explain/clarify why it is called that.
That way when fools like me read it, we don't comment it/the lines out and wonder why it doesn't boot.

Thanks.

0 Likes

#19

no worries - I have changed it anyway.

0 Likes

#20

(It's 21:54 local time but before I sign off for today)

While I can keep the thoughts together here are some things about the recent attempts to install NR.
Again: I am only wanting to relay the problems as I saw/see them and the confusion resulting.

  • I started using NR on a RPI. As it came pre-installed it was good.
  • I went through the curve of using NPM installing nodes "manually" and not via NR.
    The catch there is the command has to be run from within the .node-red directory, or the things get put in the wrong place.
  • It was also made clear to me that when updating NR from the CLI (command line) that you also had to issue the commands from within the .node-red directory.
    Again: This is fair enough, because you are doing things with/to/(what ever) in node-red.
    Not exactly sure why the directory is "hidden" but I'll get to that later.
  • After a while using NR, I got the command
bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)

sudo systemctl enable nodered.service

to update and make auto starting. It works! I did 8 RPIs with it.
So it was flagged as WORKING.

I'll be honest and say I don't know exactly how I did it on THIS machine. A x86 64 bit NUC.
Probably with the same command. (I'm getting to the hitch with the above mentioned command/s)

So: On Tuesday I got a new NUC (x86 celeron this time) machine.
I had to install Ubuntu and update it, and UPDATE it.
That seemed to go smoothly.

At that point in time there is/was no .node-red directory.

So, I diligently made it, changed into it and ran the script/commands.

It was not happy.

Errors came up on the screen something shocking and I could not get NR working to auto start.
When ever I entered node-red (or was it nodered - I can't remember) it spat out errors at me.
Missing files, bad dependencies RPI stuff and a lot of other stuff. WAY over my head.
(Keeping it brief)
I decided to start again.
Re-installed Ubuntu, updated and UPDATED it to 18.04.
Tried again to install NR.
Same errors.
Somewhere about here I posted the question.
I found all the extra stuff.
Downloaded those packages and went through the motions. From within the .node-red directory.

When complete:
There was ANOTHER directory there. This time it was:
node-red (NOT hidden.)

It took me about 40 minutes emptying all the sub directories - which were full of great stuff I had never seen before.

I put that down to the fact that now it is not needing/wanting to be in the .node-red directory.
Though why it is now node-red and not .node-red is not exactly clear.
I am a bit suspicious I have wasted time doing that and the stuff was good and could be used.
But when there were about 8 lines of RED errors and 4 YELLOW warnings, I was not confident things were good.

So, here is the confusion:
As originally working the "install command"

bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)

needed to be run from the .node-red directory.

Is that still true?
Where does this new node-red directory come into things? Ok, that is the Version 19+ and I have only updated some machines and those were updated from within NR.

To help (?) people like me, would it be better/easier(?) - though now thinking about it there is a complication about path names - if the complete path is declared?
Ok, the complete path with OS, user name and stuff could be problematic:
Rather than installing from "here" (.), install from "home" (~), as it seems that this has changed.

I am kind of asking. See the question mark 5 lines above.

I don't want to go on further, as I think I have said all that needs to be said here and don't want to continue for the sake of continuing.

Thanks.

0 Likes