Skip to main content

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.

  1. Create a dedicated service user (for example, iqserver) with limited access on the server.

  2. Install IQ Server in a directory such as /opt/sonatype-iq-server.

  3. Configure IQ Server to run as a systemd service. See the SystemD section 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

SystemD

This example shows how to run IQ Server as a native systemd service. It does not require a /etc/init.d script.

  1. Make sure the iqserver user exists (or create it).

  2. Ensure IQ Server is installed in a directory such as /opt/sonatype-iq-server.

  3. Create a file called sonatypeiq.service in the /etc/systemd/system/ directory.

    /etc/systemd/system/sonatypeiq.service
  4. 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