Start SonarQube as a Service on Linux

  • SonarQube 8.9

Hi, I would like to try and run SonarQube as a service.

I’ve followed the guide in the Documentation. The following file was created:

[Unit]
Description=SonarQube service
After=syslog.target network.target

[Service]
Type=simple
User=sonarqube
Group=sonarqube
PermissionsStartOnly=true
ExecStart=/bin/nohup /usr/lib/jvm/java-11-openjdk-11.0.16.1.1-1.el7_9.x86_64/bin/java
 -Xms32m -Xmx32m -Djava.net.preferIPv4Stack=true -jar /home/sonarqube/sonarqube8.9/lib/sonar-application-8.9.9.56886.jar
StandardOutput=syslog
LimitNOFILE=131072
LimitNPROC=8192
TimeoutStartSec=5
Restart=always
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target

I then ran the following commands:

sudo systemctl enable sonarqube.service
sudo systemctl start sonarqube.service

Next, I checked the status of the service:

sudo systemctl status sonarqube

Which returned the following:

sonarqube.service - SonarQube service
   Loaded: loaded (/etc/systemd/system/sonarqube.service; enabled; vendor preset: disabled)
   Active: failed (Result: start-limit) since Mon 2022-10-10 14:34:53 AEDT; 21s ago
  Process: 27351 ExecStart=/bin/nohup /usr/lib/jvm/java-11-openjdk-11.0.16.1.1-1.el7_9.x86_64/bin/java (code=exited, status=1/FAILURE)
 Main PID: 27351 (code=exited, status=1/FAILURE)

Oct 10 14:34:52 localhost.localdomain systemd[1]: sonarqube.service: main process exited, code=exited, status=1/FAILURE
Oct 10 14:34:52 localhost.localdomain systemd[1]: Unit sonarqube.service entered failed state.
Oct 10 14:34:52 localhost.localdomain systemd[1]: sonarqube.service failed.
Oct 10 14:34:53 localhost.localdomain systemd[1]: sonarqube.service holdoff time over, scheduling restart.
Oct 10 14:34:53 localhost.localdomain systemd[1]: Stopped SonarQube service.
Oct 10 14:34:53 localhost.localdomain systemd[1]: start request repeated too quickly for sonarqube.service
Oct 10 14:34:53 localhost.localdomain systemd[1]: Failed to start SonarQube service.
Oct 10 14:34:53 localhost.localdomain systemd[1]: Unit sonarqube.service entered failed state.
Oct 10 14:34:53 localhost.localdomain systemd[1]: sonarqube.service failed.

I then checked the logs with:

journalctl -u sonarqube
Oct 10 14:34:51 localhost.localdomain systemd[1]: Started SonarQube service.
Oct 10 14:34:51 localhost.localdomain nohup[27266]: Usage: java [options] <mainclass> [args...]
Oct 10 14:34:51 localhost.localdomain nohup[27266]: (to execute a class)
Oct 10 14:34:51 localhost.localdomain nohup[27266]: or  java [options] -jar <jarfile> [args...]
Oct 10 14:34:51 localhost.localdomain nohup[27266]: (to execute a jar file)
Oct 10 14:34:51 localhost.localdomain nohup[27266]: or  java [options] -m <module>[/<mainclass>] [args...]
Oct 10 14:34:51 localhost.localdomain nohup[27266]: java [options] --module <module>[/<mainclass>] [args...]
Oct 10 14:34:51 localhost.localdomain nohup[27266]: (to execute the main class in a module)
Oct 10 14:34:51 localhost.localdomain nohup[27266]: or  java [options] <sourcefile> [args]
Oct 10 14:34:51 localhost.localdomain nohup[27266]: (to execute a single source-file program)
Oct 10 14:34:51 localhost.localdomain nohup[27266]: Arguments following the main class, source file, -jar <jarfile>,
Oct 10 14:34:51 localhost.localdomain nohup[27266]: -m or --module <module>/<mainclass> are passed as the arguments to
Oct 10 14:34:51 localhost.localdomain nohup[27266]: main class.
Oct 10 14:34:51 localhost.localdomain nohup[27266]: where options include:
Oct 10 14:34:51 localhost.localdomain nohup[27266]: -cp <class search path of directories and zip/jar files>
Oct 10 14:34:51 localhost.localdomain nohup[27266]: -classpath <class search path of directories and zip/jar files>
Oct 10 14:34:51 localhost.localdomain nohup[27266]: --class-path <class search path of directories and zip/jar files>
Oct 10 14:34:51 localhost.localdomain nohup[27266]: A : separated list of directories, JAR archives,
Oct 10 14:34:51 localhost.localdomain nohup[27266]: and ZIP archives to search for class files.
Oct 10 14:34:51 localhost.localdomain nohup[27266]: -p <module path>
Oct 10 14:34:51 localhost.localdomain nohup[27266]: --module-path <module path>...
Oct 10 14:34:51 localhost.localdomain nohup[27266]: A : separated list of directories, each directory
Oct 10 14:34:51 localhost.localdomain nohup[27266]: is a directory of modules.
Oct 10 14:34:51 localhost.localdomain nohup[27266]: --upgrade-module-path <module path>...
Oct 10 14:34:51 localhost.localdomain systemd[1]: sonarqube.service: main process exited, code=exited, status=1/FAILURE
Oct 10 14:34:51 localhost.localdomain systemd[1]: Unit sonarqube.service entered failed state.
Oct 10 14:34:51 localhost.localdomain systemd[1]: sonarqube.service failed.
Oct 10 14:34:52 localhost.localdomain systemd[1]: sonarqube.service holdoff time over, scheduling restart.
Oct 10 14:34:52 localhost.localdomain systemd[1]: Stopped SonarQube service.
Oct 10 14:34:52 localhost.localdomain systemd[1]: Started SonarQube service.
Oct 10 14:34:52 localhost.localdomain nohup[27297]: Usage: java [options] <mainclass> [args...]
Oct 10 14:34:52 localhost.localdomain nohup[27297]: (to execute a class)
Oct 10 14:34:52 localhost.localdomain nohup[27297]: or  java [options] -jar <jarfile> [args...]
Oct 10 14:34:52 localhost.localdomain nohup[27297]: (to execute a jar file)
Oct 10 14:34:52 localhost.localdomain nohup[27297]: or  java [options] -m <module>[/<mainclass>] [args...]
Oct 10 14:34:52 localhost.localdomain nohup[27297]: java [options] --module <module>[/<mainclass>] [args...]
Oct 10 14:34:52 localhost.localdomain nohup[27297]: (to execute the main class in a module)
Oct 10 14:34:52 localhost.localdomain nohup[27297]: or  java [options] <sourcefile> [args]
Oct 10 14:34:52 localhost.localdomain nohup[27297]: (to execute a single source-file program)
Oct 10 14:34:52 localhost.localdomain nohup[27297]: Arguments following the main class, source file, -jar <jarfile>,
Oct 10 14:34:52 localhost.localdomain nohup[27297]: -m or --module <module>/<mainclass> are passed as the arguments to
Oct 10 14:34:52 localhost.localdomain nohup[27297]: main class.
Oct 10 14:34:52 localhost.localdomain nohup[27297]: where options include:
Oct 10 14:34:52 localhost.localdomain nohup[27297]: -cp <class search path of directories and zip/jar files>
Oct 10 14:34:52 localhost.localdomain nohup[27297]: -classpath <class search path of directories and zip/jar files>
Oct 10 14:34:52 localhost.localdomain nohup[27297]: --class-path <class search path of directories and zip/jar files>
Oct 10 14:34:52 localhost.localdomain nohup[27297]: A : separated list of directories, JAR archives,
Oct 10 14:34:52 localhost.localdomain nohup[27297]: and ZIP archives to search for class files.
Oct 10 14:34:52 localhost.localdomain nohup[27297]: -p <module path>
Oct 10 14:34:52 localhost.localdomain nohup[27297]: --module-path <module path>...
Oct 10 14:34:52 localhost.localdomain nohup[27297]: A : separated list of directories, each directory
Oct 10 14:34:52 localhost.localdomain nohup[27297]: is a directory of modules.
Oct 10 14:34:52 localhost.localdomain nohup[27297]: --upgrade-module-path <module path>...
Oct 10 14:34:52 localhost.localdomain nohup[27297]: A : separated list of directories, each directory
Oct 10 14:34:52 localhost.localdomain nohup[27297]: is a directory of modules that replace upgradeable
Oct 10 14:34:52 localhost.localdomain nohup[27297]: modules in the runtime image
Oct 10 14:34:52 localhost.localdomain nohup[27297]: --add-modules <module name>[,<module name>...]
Oct 10 14:34:52 localhost.localdomain systemd[1]: sonarqube.service: main process exited, code=exited, status=1/FAILURE
Oct 10 14:34:52 localhost.localdomain systemd[1]: Unit sonarqube.service entered failed state.
Oct 10 14:34:52 localhost.localdomain systemd[1]: sonarqube.service failed.
Oct 10 14:34:52 localhost.localdomain systemd[1]: sonarqube.service holdoff time over, scheduling restart.
Oct 10 14:34:52 localhost.localdomain systemd[1]: Stopped SonarQube service.
Oct 10 14:34:52 localhost.localdomain systemd[1]: Started SonarQube service.
Oct 10 14:34:52 localhost.localdomain nohup[27315]: Usage: java [options] <mainclass> [args...]
Oct 10 14:34:52 localhost.localdomain nohup[27315]: (to execute a class)
Oct 10 14:34:52 localhost.localdomain nohup[27315]: or  java [options] -jar <jarfile> [args...]
Oct 10 14:34:52 localhost.localdomain nohup[27315]: (to execute a jar file)
Oct 10 14:34:52 localhost.localdomain nohup[27315]: or  java [options] -m <module>[/<mainclass>] [args...]
Oct 10 14:34:52 localhost.localdomain nohup[27315]: java [options] --module <module>[/<mainclass>] [args...]
Oct 10 14:34:52 localhost.localdomain nohup[27315]: (to execute the main class in a module)
Oct 10 14:34:52 localhost.localdomain nohup[27315]: or  java [options] <sourcefile> [args]
Oct 10 14:34:52 localhost.localdomain nohup[27315]: (to execute a single source-file program)
Oct 10 14:34:52 localhost.localdomain nohup[27315]: Arguments following the main class, source file, -jar <jarfile>,
Oct 10 14:34:52 localhost.localdomain nohup[27315]: -m or --module <module>/<mainclass> are passed as the arguments to
Oct 10 14:34:52 localhost.localdomain nohup[27315]: main class.
Oct 10 14:34:52 localhost.localdomain nohup[27315]: where options include:
Oct 10 14:34:52 localhost.localdomain nohup[27315]: -cp <class search path of directories and zip/jar files>
Oct 10 14:34:52 localhost.localdomain nohup[27315]: -classpath <class search path of directories and zip/jar files>
Oct 10 14:34:52 localhost.localdomain nohup[27315]: --class-path <class search path of directories and zip/jar files>
Oct 10 14:34:52 localhost.localdomain nohup[27315]: A : separated list of directories, JAR archives,
Oct 10 14:34:52 localhost.localdomain nohup[27315]: and ZIP archives to search for class files.
Oct 10 14:34:52 localhost.localdomain nohup[27315]: -p <module path>
Oct 10 14:34:52 localhost.localdomain nohup[27315]: --module-path <module path>...
Oct 10 14:34:52 localhost.localdomain nohup[27315]: A : separated list of directories, each directory
Oct 10 14:34:52 localhost.localdomain nohup[27315]: is a directory of modules.
Oct 10 14:34:52 localhost.localdomain nohup[27315]: --upgrade-module-path <module path>...
Oct 10 14:34:52 localhost.localdomain nohup[27315]: A : separated list of directories, each directory
Oct 10 14:34:52 localhost.localdomain systemd[1]: sonarqube.service: main process exited, code=exited, status=1/FAILURE
Oct 10 14:34:52 localhost.localdomain systemd[1]: Unit sonarqube.service entered failed state.
Oct 10 14:34:52 localhost.localdomain systemd[1]: sonarqube.service failed.
Oct 10 14:34:52 localhost.localdomain systemd[1]: sonarqube.service holdoff time over, scheduling restart.
Oct 10 14:34:52 localhost.localdomain systemd[1]: Stopped SonarQube service.
Oct 10 14:34:52 localhost.localdomain systemd[1]: Started SonarQube service.
Oct 10 14:34:52 localhost.localdomain nohup[27333]: Usage: java [options] <mainclass> [args...]
Oct 10 14:34:52 localhost.localdomain nohup[27333]: (to execute a class)
Oct 10 14:34:52 localhost.localdomain nohup[27333]: or  java [options] -jar <jarfile> [args...]
Oct 10 14:34:52 localhost.localdomain nohup[27333]: (to execute a jar file)
Oct 10 14:34:52 localhost.localdomain nohup[27333]: or  java [options] -m <module>[/<mainclass>] [args...]
Oct 10 14:34:52 localhost.localdomain nohup[27333]: java [options] --module <module>[/<mainclass>] [args...]
Oct 10 14:34:52 localhost.localdomain nohup[27333]: (to execute the main class in a module)
Oct 10 14:34:52 localhost.localdomain nohup[27333]: or  java [options] <sourcefile> [args]
Oct 10 14:34:52 localhost.localdomain nohup[27333]: (to execute a single source-file program)
Oct 10 14:34:52 localhost.localdomain nohup[27333]: Arguments following the main class, source file, -jar <jarfile>,
Oct 10 14:34:52 localhost.localdomain nohup[27333]: -m or --module <module>/<mainclass> are passed as the arguments to
Oct 10 14:34:52 localhost.localdomain nohup[27333]: main class.
Oct 10 14:34:52 localhost.localdomain nohup[27333]: where options include:
Oct 10 14:34:52 localhost.localdomain nohup[27333]: -cp <class search path of directories and zip/jar files>
Oct 10 14:34:52 localhost.localdomain nohup[27333]: -classpath <class search path of directories and zip/jar files>
Oct 10 14:34:52 localhost.localdomain nohup[27333]: --class-path <class search path of directories and zip/jar files>
Oct 10 14:34:52 localhost.localdomain nohup[27333]: A : separated list of directories, JAR archives,
Oct 10 14:34:52 localhost.localdomain nohup[27333]: and ZIP archives to search for class files.
Oct 10 14:34:52 localhost.localdomain nohup[27333]: -p <module path>
Oct 10 14:34:52 localhost.localdomain nohup[27333]: --module-path <module path>...
Oct 10 14:34:52 localhost.localdomain nohup[27333]: A : separated list of directories, each directory
Oct 10 14:34:52 localhost.localdomain nohup[27333]: is a directory of modules.
Oct 10 14:34:52 localhost.localdomain nohup[27333]: --upgrade-module-path <module path>...
Oct 10 14:34:52 localhost.localdomain systemd[1]: sonarqube.service: main process exited, code=exited, status=1/FAILURE
Oct 10 14:34:52 localhost.localdomain systemd[1]: Unit sonarqube.service entered failed state.
Oct 10 14:34:52 localhost.localdomain systemd[1]: sonarqube.service failed.
Oct 10 14:34:52 localhost.localdomain systemd[1]: sonarqube.service holdoff time over, scheduling restart.
Oct 10 14:34:52 localhost.localdomain systemd[1]: Stopped SonarQube service.
Oct 10 14:34:52 localhost.localdomain systemd[1]: Started SonarQube service.
Oct 10 14:34:52 localhost.localdomain nohup[27351]: Usage: java [options] <mainclass> [args...]
Oct 10 14:34:52 localhost.localdomain nohup[27351]: (to execute a class)
Oct 10 14:34:52 localhost.localdomain nohup[27351]: or  java [options] -jar <jarfile> [args...]
Oct 10 14:34:52 localhost.localdomain nohup[27351]: (to execute a jar file)
Oct 10 14:34:52 localhost.localdomain nohup[27351]: or  java [options] -m <module>[/<mainclass>] [args...]
Oct 10 14:34:52 localhost.localdomain nohup[27351]: java [options] --module <module>[/<mainclass>] [args...]
Oct 10 14:34:52 localhost.localdomain nohup[27351]: (to execute the main class in a module)
Oct 10 14:34:52 localhost.localdomain nohup[27351]: or  java [options] <sourcefile> [args]
Oct 10 14:34:52 localhost.localdomain nohup[27351]: (to execute a single source-file program)
Oct 10 14:34:52 localhost.localdomain nohup[27351]: Arguments following the main class, source file, -jar <jarfile>,
Oct 10 14:34:52 localhost.localdomain nohup[27351]: -m or --module <module>/<mainclass> are passed as the arguments to
Oct 10 14:34:52 localhost.localdomain nohup[27351]: main class.
Oct 10 14:34:52 localhost.localdomain nohup[27351]: where options include:
Oct 10 14:34:52 localhost.localdomain nohup[27351]: -cp <class search path of directories and zip/jar files>
Oct 10 14:34:52 localhost.localdomain systemd[1]: sonarqube.service: main process exited, code=exited, status=1/FAILURE
Oct 10 14:34:52 localhost.localdomain systemd[1]: Unit sonarqube.service entered failed state.
Oct 10 14:34:52 localhost.localdomain systemd[1]: sonarqube.service failed.
Oct 10 14:34:53 localhost.localdomain systemd[1]: sonarqube.service holdoff time over, scheduling restart.
Oct 10 14:34:53 localhost.localdomain systemd[1]: Stopped SonarQube service.
Oct 10 14:34:53 localhost.localdomain systemd[1]: start request repeated too quickly for sonarqube.service
Oct 10 14:34:53 localhost.localdomain systemd[1]: Failed to start SonarQube service.
Oct 10 14:34:53 localhost.localdomain systemd[1]: Unit sonarqube.service entered failed state.
Oct 10 14:34:53 localhost.localdomain systemd[1]: sonarqube.service failed.

I’m not sure where I’m going wrong, whether this is an issue with the service file or something to do with permissions.

I also checked out this thread on stack which suggested to make a change to the sonar.sh file: linux - SonarQube 7.2 won't start with systemd on CentOS 7 - Stack Overflow. The errors persist though.

Would appreciate any help

What do the logs say? Troubleshooting | SonarQube Docs

Actually figured it out. Had to configure something in the sonar.sh file