Run IQ Server as a Service
The server can be run as a service or daemon. This is recommended to ensure the server will restart when the operating system reboots. Following instructions are for Linux environments that use systemd.
See the KB to run as a service on a Windows Server
Note
This topic applies to IQ Server installations using the bundled JDK distribution. If you are using the standalone JAR distribution, service configuration differs.
Create a dedicated service user (for example,
iqserver) with limited access on the server.Install IQ Server in a directory such as /opt/sonatype-iq-server.
Configure IQ Server to run as a
systemdservice. See theSystemDsection below.
Set directory permissions
Create a dedicated user with limited access for the service.
The user needs full access rights to the server installation directory and the sonatype-work directory listed in the config YAML.
The following command grants service user permissions:
chown -R iqserver /opt/sonatype-iq-server
These steps assume that a dedicated service user already exists and owns both the IQ Server installation directory and the configured sonatype-work directory.
Note
The command below applies to IQ Server installations that include the bundled JDK. If you are using a legacy init.d wrapper script or older service script, the startup usage is different and uses
Usage: sonatype-iq-server console/start/stop
Bundled JDK distribution (Recommended)
When using the IQ Server distribution that includes a bundled JDK, start IQ Server using the provided wrapper script:
<install-dir>/bin/nexus-iq-server server <path/to/config.yml>
The nexus-iq-server wrapper script is included with the bundled JDK distribution at <install-dir>/bin/nexus-iq-server.
For IQ Server 205 and later, custom startup scripts that call the server JAR directly should reference the server JAR in the jars directory, for example:
./jars/insight-brain-service-*-server.jar
Note
If you use a custom startup script with a separately installed Java runtime, use a Java version supported by your IQ Server version. See the Java Compatibility Matrix.
The bundled distribution also includes example service scripts and a sample configuration file in the <install-dir>/examples directory.
SystemD
This example shows how to run IQ Server as a native systemd service. It does not require a /etc/init.d script.
Make sure the
iqserveruser exists (or create it).Ensure IQ Server is installed in a directory such as
/opt/sonatype-iq-server.Create a file called
sonatypeiq.servicein the/etc/systemd/system/directory./etc/systemd/system/sonatypeiq.service
Add the following script and save the file:
[Unit] Description=Sonatype Nexus IQ Server After=network-online.target [Service] Type=simple User=iqserver WorkingDirectory=/opt/sonatype-iq-server Environment='JAVA_OPTS=-Xms8g -Xmx8g -XX:+UseG1GC' ExecStart=/opt/sonatype-iq-server/bin/nexus-iq-server server config.yml Restart=on-failure TimeoutStopSec=600 StandardOutput=journal StandardError=append:/opt/sonatype-iq-server/stderr.log [Install] WantedBy=multi-user.target
Note
Use JAVA_OPTS to pass Java configuration parameters to the bundled IQ Server startup script when running IQ Server as a systemd service. To change the heap size, set -Xms and -Xmx in JAVA_OPTS. For heap sizing guidance, see Estimating Heap Sizes.
Activate the service with the following commands:
sudo systemctl daemon-reload sudo systemctl enable sonatypeiq.service sudo systemctl start sonatypeiq.service sudo systemctl status sonatypeiq.service
Native Linux installers from the community
Community-provided native installers for Linux are available to set up the server to run as a service, however, they are not officially supported.
See github.com/sonatype-nexus-community/nexus-iq-server-installer