9

I installed the following unit file for an Nodejs Express Server:

 [Unit]
 Description=Server for SpeedBot
 After=network.target

 [Service]
 ExecStart=/var/www/SpeedBot/server.js
 Restart=always
 User=nobody
 Group=nobody
 Environment=PATH=/usr/bin:/usr/local/bin
 Environment=NODE_ENV=production
 WorkingDirectory=/home/pi/SpeedBot/server.js

 [Install]
 WantedBy=multi-user.target

When I run it and do: service speedbotserver status i get:

● speedbotserver.service - Server for SpeedBot
   Loaded: loaded (/etc/systemd/system/speedbotserver.service; disabled)
   Active: failed (Result: start-limit) since Thu 2017-06-29 01:31:18 UTC; 18h ago 
  Process: 19189 ExecStart=/var/www/SpeedBot/server.js (code=exited, status=216/GROUP)
 Main PID: 19189 (code=exited, status=216/GROUP)
  • .js file does not execute. Let me know how this server.js normally run in your system? I mean, is there any other program that runs server.js i. e. node server.js something like that – Sourav Jun 29 '17 at 20:28
  • 1
    This particular instance uses the #!/usr/bin/env node line at the start and I made the file executable using chmod +x. Will try ExecStart=/usr/local/bin/node /var/www/SpeedBot/server.js – medicengonzo Jun 30 '17 at 03:26
  • Tried ExecStart=/usr/bin/node /var/www/SpeedBot/server.js and same result. – medicengonzo Jun 30 '17 at 03:39
  • What worked for me is to remove the User=myname line, since I am already running it as systemd --user this turned out not to be necessary. I didn't have a Group= line which made this error quite confusing. – Luc Apr 07 '22 at 10:29

3 Answers3

9

Group=nobody

When the error message tells you that there's a problem setting the group that the service runs as, which is what that status code is doing, really your first thought should be "Have I configured a valid group for this service?"

Do not run services as nobody, by the way. This is a bad idea that the world learned not to do in the 1990s. nobody has a specific usage relating to NFS that means that it is the (apparent) owner of (possibly many) things in the filesystem. It is not suitable for running dæmon processes, whose user accounts should generally only own a limited amount of things in the filesystem that are directly related to their operation.

Run your service as a dedicated user account that is specific to the service.

Further reading

JdeBP
  • 68,745
2

Group=nobody Group should be same as your user. If you haven't create user for SonarQube then create it first.

Click here to follow step by step guideline for more info

You will need to configure SonarQube to run as a sonar user. You can do this with the following command:

sudo nano /opt/sonarqube/bin/linux-x86-64/sonar.sh

Make the following changes:

RUN_AS_USER=sonar

save and close file then use this user to your Service property

Hemant
  • 21
1

You can try with the below unit configuration:

 [Unit]
 Description=Server for SpeedBot
 After=network.target

 [Service]
  ExecStart=/bin/sh -c "exec /usr/bin/node /var/www/SpeedBot/server.js"
  Restart=always
  User=nobody
  Group=nobody
  Environment=PATH=/usr/bin:/usr/local/bin
  Environment=NODE_ENV=production
  WorkingDirectory=/var/www/SpeedBot

 [Install]
 WantedBy=multi-user.target
Sourav
  • 1,343