Run IQ Server as a Service
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.
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
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
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