Ok I think I finally got sonarqube to start under init.d. Your guide about configuring as a service is missing a lot.
Basically had to change the process startup command in the init.d shell script at /etc/init.d/sonar (symbolic link) that was provided on the guide here
https://docs.sonarqube.org/latest/setup/operate-server/
so that it runs as sonarqube user and not root, had to ensure all old root owned logs were deleted and finally had to chown of the symbolic link used by init.d.
I had to change this in etc/init.d/sonar:
/usr/bin/sonar $*
to this:
sudo -u sonarqube /usr/bin/sonar $*
I also changed the owner of the sonar symbolic link but had to use a different option to change the link and not the link target, like this:
sudo chown -h sonarqube /etc/init.d/sonar
Note that for Ubuntu the service registration uses a different command than chkconfig called sysv-rc-conf to install the service:
sysv-rc-conf sonar on (which is equivalent to “chkconfig sonar enable”).
You should probably update your guide.
Now I’m just fighting the jvm out-of-memory error and then onto pointing sonarqube to a postgresql instance…hmmph…soon I hope. Here’s the out of memory information that I found in /opt/sonarqube/sonarqube-7.9.1/hs_err_pid2665.log (just happened to find this log when not finding anything in the logs folder stating the error):
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 89522176 bytes for committing reserved memory.
# Possible reasons:
# The system is out of physical RAM or swap space
# The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap
# Possible solutions:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Decrease Java heap size (-Xmx/-Xms)
# Decrease number of Java threads
# Decrease Java thread stack sizes (-Xss)
# Set larger code cache with -XX:ReservedCodeCacheSize=
# This output file may be truncated or incomplete.
#
# Out of Memory Error (os_linux.cpp:2830), pid=2665, tid=2671
#
# JRE version: (11.0.5+9) (build )
# Java VM: OpenJDK 64-Bit Server VM (11.0.5+9-201910111809, mixed mode, aot, sharing, tiered, compressed oops, serial gc, linux-amd64)
# Core dump will be written. Default location: /opt/sonarqube/sonarqube-7.9.1/core
#
--------------- S U M M A R Y ------------
Command Line: -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/opt/sonarqube/sonarqube-7.9.1/temp --add-opens=java.base/java.util=ALL-UNNAMED -Xmx5
12m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Dhttp.nonProxyHosts=localhost|127.*|[::1] org.sonar.ce.app.CeServer /opt/sonarqube/sonarqube-7.9.1/temp/sq-process126
82350297613366166properties
Host: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, 1 cores, 4G, Ubuntu 16.04.5 LTS
Time: Mon Oct 21 14:09:35 2019 UTC elapsed time: 0 seconds (0d 0h 0m 0s)
Any thoughts on this error?
James