How to change the niceness value on nodered.service

Hi all,

I want to give a higher priority to Node-RED process by setting the nice value to -20.

However, I can't seems to find the option in the nodered.service file as described here :

  • Change Node-RED's nice value . Dave's installer for the Pi sets niceness at 10 which is lower than the average. Try setting to zero or even a negative number to boost the priority of the Node-RED process compared to others on the system. This may, of course, have a negative impact on other processes running on the same machine. This is changed in the systemd service file that runs Node-RED on bootup.

Below the extract of my nodered.service file:

# define an optional environment file in Node-RED's user directory to set custom variables externally
# uncomment and edit next line if you need an http proxy
# uncomment the next line for a more verbose log output
# uncomment next line if you need to wait for time sync before starting
#ExecStartPre=/bin/bash -c '/bin/journalctl -b -u systemd-timesyncd | /bin/grep -q "systemd-timesyncd.* Synchronized to time server"'

ExecStart=/usr/bin/env node-red-pi $NODE_OPTIONS $NODE_RED_OPTIONS
#ExecStart=/usr/bin/env node $NODE_OPTIONS red.js $NODE_RED_OPTIONS
# Use SIGINT to stop
# Auto restart on crash
# Tag things in the log


I know manually adding sudo nice -n -20 front of the ExecStart command works, as follows:
ExecStart=sudo nice -n -20 /usr/bin/env node-red-pi $NODE_OPTIONS $NODE_RED_OPTIONS

But this also means that Node-RED is therefore running as root, and not as normal user...

Any workaround to make the nice value -20 but running as normal user ?

I would go to that thread you mentioned and ask there how to set the nice value.

It is said that you use systemd but that's above my knowledge set.

Please don't worry about asking dumb questions. In reality the only DUMB question is the one you don't ask, as you suffer both times.
1 for not knowing.
2 for not asking.

Hope that helps.

See linux - Set niceness value in a systemd user service - Super User

Why do want to do this? The nice value is rarely important.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.