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 :
nicevalue . Dave's installer for the Pi sets niceness at
10which 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:
Environment="NODE_OPTIONS=--max_old_space_size=2048" # define an optional environment file in Node-RED's user directory to set custom variables externally EnvironmentFile=-/home/An04Mal_B0SS-Us3R/.node-red/environment # 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" # 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 KillSignal=SIGINT # Auto restart on crash Restart=on-failure RestartSec=20 # Tag things in the log SyslogIdentifier=Node-RED #StandardOutput=syslog [Install] WantedBy=multi-user.target
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 ?