Skip to content

Instantly share code, notes, and snippets.

@esamson
Last active April 28, 2019 14:56
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save esamson/97d183e3225a2965d979 to your computer and use it in GitHub Desktop.
Save esamson/97d183e3225a2965d979 to your computer and use it in GitHub Desktop.
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
@dtonhofer
Copy link

@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
Copy link

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

@dtonhofer
Copy link

@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
Copy link

@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