Skip to content

Instantly share code, notes, and snippets.

@drmalex07
Created October 30, 2019 11:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save drmalex07/0d2a2525ad72f1c060e9f29bb108176a to your computer and use it in GitHub Desktop.
Save drmalex07/0d2a2525ad72f1c060e9f29bb108176a to your computer and use it in GitHub Desktop.
A very simple systemd service for a Spring-Boot executable JAR. #systemd #spring-boot

An example service definition under /etc/systemd/system/foo.service:

[Unit]

Description=Foo Service
After=network.target 

[Service]

Type=simple

# Place config/application*.properties under working directory
WorkingDirectory=/var/local/foo

ExecStart=/usr/bin/java -jar /opt/foo/foo-service-1.0.0-exec.jar

User=user
Group=user
UMask=0002

# Note: Sending a SIGINT (as in CTRL-C) results in an exit code of 130 (which is normal)
KillMode=process
KillSignal=SIGINT
SuccessExitStatus=130
TimeoutStopSec=10

StandardOutput=journal
StandardError=journal

[Install]

WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment