Node-red and OpenHAB start-up

Platform information:

  • Hardware: Intel/4G RAM/64GB SSD
  • OS: Ubuntu Server 18.04lts
  • Java Runtime Environment: Zulu8
  • openHAB version: 2.4 Snapshot
  • Issue of the topic:

When starting the server, node-red will be ready first and start post REST api requests to openHAB. This is because I am using the node-red-contrib-openHAB2 nodes.

This generates errors in node-red and also in the openHAB log.

If I block node-red and let OH start and start node-red once openHAB has finished starting (2 minutes, if that) then everything is fine.
The errors of not great importance. Once OH has started everything stabilises and it’s fine.

My question is:

How can I delay the start of node-red when the system starts.
I have tried modifying the .service file to wait for the openhab2 service to be started but the openhab2.service starts before openhab has finished it’s start up (If that makes sense). So that doesn’t work

Is there a way to delay a service start for an arbitrary amount of time?

I had to search to find it again. There is an ExecSleep command you can add to the .service file.

The annoying part though it’s I think that will delay restarted and manual calls as well.

Beyond that over no ideas.

The 3rd answer is actually very good

In the /etc/systems/system or /lib/systemd/system folder where nodered.service is
(In my case /lib/systemd/system)

Create a new file called nodered.timer with the following content:

[Unit]
Description=Run nodered 5 mins after boot

[Timer]
OnBootSec=5min

[Install]
WantedBy=timers.target
1 Like

Hi vince can you please be more spicfic , i have same issue
using Ub 16.04
also NR starts then OH
what exclty did you do with this timer file ,i dont see any coomand to start Node or delay the service start
if you can please explain!

Locate your nodered.service file
It should be either in : /etc/systems/system or /lib/systemd/system

so add to the file the timer part?

non-root user to run as

WorkingDirectory=/home/openhab/
User=openhab
Group=openhab

[Timer]
OnBootSec=5min

[Install]
WantedBy=multi-user.target

No,

You create another file called nodered.timer in the same directory/folder

With this in it:

[Unit]
Description=Run nodered 5 mins after boot

[Timer]
OnBootSec=5min

[Install]
WantedBy=timers.target

ok done will test thanks

still dont see how the file will tell node to wait…

but i have no clue in linux… i am bulding a server with GUI :slight_smile:

Apparently, linux systemd process will find the timer file and apply the delay to the service:

https://wiki.archlinux.org/index.php/Systemd/Timers

1 Like