systemd - My custom service exits with status code 216/GROUP

19,658

Solution 1

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

Solution 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

Solution 3

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
Share:
19,658

Related videos on Youtube

medicengonzo
Author by

medicengonzo

Updated on September 18, 2022

Comments

  • medicengonzo
    medicengonzo over 1 year

    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)
    
    • medicengonzo
      medicengonzo almost 7 years
      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
      medicengonzo almost 7 years
      Tried ExecStart=/usr/bin/node /var/www/SpeedBot/server.js and same result.
    • Luc
      Luc about 2 years
      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.
  • medicengonzo
    medicengonzo almost 7 years
    I tried it and it gives me the same error message.