Skip to content

Instantly share code, notes, and snippets.

@esamson

esamson/.gitignore

Last active Apr 28, 2019
Embed
What would you like to do?
systemd service file for sonatype nexus. Put this in `$HOME/.config/systemd/user/nexus.service`. Launch with `systemctl --user start nexus`.
default.target.wants/
nexus
[Unit]
Description=Sonatype Nexus
[Service]
Type=forking
PIDFile=%h/.local/opt/nexus/bin/jsw/linux-x86-64/nexus.pid
ExecStart=%h/.local/opt/nexus/bin/nexus start
ExecReload=%h/.local/opt/nexus/bin/nexus restart
ExecStop=%h/.local/opt/nexus/bin/nexus stop
[Install]
Alias=nexus
WantedBy=default.target
@stephenfuqua

This comment has been minimized.

Copy link

@stephenfuqua stephenfuqua commented Jul 29, 2015

Great script. I left out the PIDFile originally and suffered for it. Without it, systemd does not realize that the service is actually starting and it immediately kills the service.

@farahfa

This comment has been minimized.

Copy link

@farahfa farahfa commented Nov 30, 2016

In 2.14.0-01 there's no nexus.pid there's only wrapper.. Should I use that instead?

@tearsakura

This comment has been minimized.

Copy link

@tearsakura tearsakura commented Jan 17, 2017

on nexus 3.2

[Unit]
Description=nexus service
After=network.target
[Service]
Type=forking
ExecStart=/opt/nexus/bin/nexus start
ExecStop=/opt/nexus/bin/nexus stop
User=nexus
Restart=on-abort
[Install]
WantedBy=multi-user.target

@lbruun

This comment has been minimized.

Copy link

@lbruun lbruun commented Nov 11, 2017

Nexus 3.6 on CentOS 7

Note that I needed to set the INSTALL4J_JAVA_HOME env var, as I do not have a globally defined java in the path. Also I needed to increase the number of file descriptors, i.e. the LimitNOFILE property.

[Unit]
Description=Sonatype Nexus Repository Manager
After=network.target

[Service]
Type=forking
ExecStart=/apps/nexus/current/bin/nexus start
ExecStop=/apps/nexus/current/bin/nexus stop
User=nexus
Restart=on-abort
Environment=INSTALL4J_JAVA_HOME=/foo/bar/jre8
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target

@dtonhofer

This comment has been minimized.

Copy link

@dtonhofer dtonhofer commented Dec 31, 2018

@Ibruun's solution is the one currently used by Sonatype at

https://help.sonatype.com/repomanager3/installation/run-as-a-service#RunasaService-systemd

But the fact that systemd still starts an (really complex) init script /apps/nexus/current/bin/nexus is jarring; that's not how it is supposed to be done....

@glynnforrest

This comment has been minimized.

Copy link

@glynnforrest glynnforrest commented Apr 27, 2019

@dtonhofer instead of ./bin/nexus start, do you think ./bin/nexus run would work with Type=simple?

@dtonhofer

This comment has been minimized.

Copy link

@dtonhofer dtonhofer commented Apr 28, 2019

@glynnforrest I don't know, you will have to try. But there is no good reason to change from the forking modus, is there?

@glynnforrest

This comment has been minimized.

Copy link

@glynnforrest glynnforrest commented Apr 28, 2019

@dtonhofer I did run it but wasn't sure if it would break nexus in some subtle way. nexus run spits the logs out to stdout so they appear in the systemd journal, which is quite handy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.