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)
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 IQ Service After=network-online.target [Service] Type=forking ExecStart=/opt/sonatype-iq-server/sonatype-iq-server start ExecStop=/opt/sonatype-iq-server/sonatype-iq-server stop WorkingDirectory=/opt/sonatype-iq-server User=iqserver Restart=on-abort TimeoutSec=600 [Install] WantedBy=multi-user.target
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