Restarting node-red service in Bookworm OS

Topics about the Software of Revolution Pi
Post Reply
Manikandan_pilz
Posts: 37
Joined: 31 Mar 2022, 16:10

Restarting node-red service in Bookworm OS

Post by Manikandan_pilz »

Hi,

I recently upgraded my Revolution Pi Connect+ from Stretch to Bookworm OS. In my Node-RED application, I used to restart the Node-RED service once a week using the sudo node-red-restart command in an Exec node.

With the latest release, it appears that running sudo from within Node-RED is no longer supported due to the new sandboxing and privilege restrictions.

I am looking for recommended methods or best practices to achieve the following:

Restart Node-RED at a scheduled time or based on certain application variables.

Reboot the entire hardware once a week.

Ideally, the solution should allow some dynamic control from Node-RED (e.g., conditional restart based on variable values) while complying with the Bookworm OS restrictions.

Any guidance, examples, or suggested approaches would be highly appreciated.

Thank you in advance!

Best Regards,
Mani
Manikandan_pilz
Posts: 37
Joined: 31 Mar 2022, 16:10

Re: Restarting node-red service in Bookworm OS

Post by Manikandan_pilz »

Hello Team ,
I was able to manage to execute the sudo commands form my node-red application.
Below are the steps or procedures I have done on my device.
1. Edited the ‘sudo nano /lib/systemd/system/nodered.service‘

Code: Select all

# systemd sandboxing process
	ProtectSystem=strict
	ProtectControlGroups=yes
	ProtectKernelModules=no
	ProtectKernelTunables=no
2. Then created the override file with the below settings.

Code: Select all

### Editing /etc/systemd/system/nodered.service.d/override.conf
### Anything between here and the comment below will become the new contents of the file

	[Service]
	NoNewPrivileges=no
	ProtectSystem=on
	PrivateTmp=yes
3. finally Added the service for node-red restart and reboot in sudo visudo

Code: Select all

	nodered ALL=NOPASSWD: /bin/systemctl restart nodered.service, /sbin/reboot
	Defaults:nodered !requiretty
4. From my node-red exec node , using sudo /sbin/reboot and sudo /bin/systemctl restart nodered.service

Request and Suggestions:
1. Missing documentation for the file ‘/lib/systemd/system/nodered.service‘ – please provide more information for each of contents present in this file.
2. As the node-red is running under the user node-red , I would recommend to develop a node form revolution pi to perform any sudo commands form the node-red.


I’m not certain if this is the most appropriate way to implement the functionality while ensuring security and avoiding potential vulnerabilities.
Kindly advise if anything can be improved with this implemented approach or advise the right approach without comprising the security of the system


Best Regards,
Mani
User avatar
nicolaiB
KUNBUS
Posts: 1131
Joined: 21 Jun 2018, 10:33
Location: Berlin
Contact:

Re: Restarting node-red service in Bookworm OS

Post by nicolaiB »

Another way to implement this is a cronjob

Nicolai
Nicolai
Manikandan_pilz
Posts: 37
Joined: 31 Mar 2022, 16:10

Re: Restarting node-red service in Bookworm OS

Post by Manikandan_pilz »

Thank you, Nicolai, for suggesting the cronjob option.

Do you think implementing a cronjob would offer a safer and more reliable approach compared to the current method I’ve used

Also, restarting the service or rebooting the system depends on my node-red variable status any recommendations?

Best Regards,
Mani
Post Reply