mirror of
https://github.com/hanzomsg/nats-server.git
synced 2026-10-30 20:27:34 +00:00
In commit e80d0a45 I made various updates to one of the example systemd service
scripts, but one change causes breakage if and only if the service file is
itself named `nats.service` when installed.
We now know that some folks are doing just that, automatically; it's bad to
have a config file which only works if it has certain names (and a little
surprising that systemd doesn't detect that the alias matches its current name
and filters).
So turn that directive into a commented-out suggestion.
87 lines
2.2 KiB
Desktop File
87 lines
2.2 KiB
Desktop File
[Unit]
|
|
Description=NATS Server
|
|
After=network-online.target ntp.service
|
|
|
|
# If you use a dedicated filesystem for JetStream data, then you might use something like:
|
|
# ConditionPathIsMountPoint=/srv/jetstream
|
|
# See also Service.ReadWritePaths
|
|
|
|
[Service]
|
|
Type=simple
|
|
EnvironmentFile=-/etc/default/nats-server
|
|
ExecStart=/usr/sbin/nats-server -c /etc/nats-server.conf
|
|
ExecReload=/bin/kill -s HUP $MAINPID
|
|
ExecStop=/bin/kill -s SIGINT $MAINPID
|
|
|
|
User=nats
|
|
Group=nats
|
|
|
|
Restart=always
|
|
RestartSec=5
|
|
# The nats-server uses SIGUSR2 to trigger using Lame Duck Mode (LDM) shutdown
|
|
KillSignal=SIGUSR2
|
|
# You might want to adjust TimeoutStopSec too.
|
|
|
|
# Capacity Limits
|
|
# JetStream requires 2 FDs open per stream.
|
|
LimitNOFILE=800000
|
|
# Environment=GOMEMLIMIT=12GiB
|
|
# You might find it better to set GOMEMLIMIT via /etc/default/nats-server,
|
|
# so that you can change limits without needing a systemd daemon-reload.
|
|
|
|
# Hardening
|
|
CapabilityBoundingSet=
|
|
LockPersonality=true
|
|
MemoryDenyWriteExecute=true
|
|
NoNewPrivileges=true
|
|
PrivateDevices=true
|
|
PrivateTmp=true
|
|
PrivateUsers=true
|
|
ProcSubset=pid
|
|
ProtectClock=true
|
|
ProtectControlGroups=true
|
|
ProtectHome=true
|
|
ProtectHostname=true
|
|
ProtectKernelLogs=true
|
|
ProtectKernelModules=true
|
|
ProtectKernelTunables=true
|
|
ProtectSystem=strict
|
|
ReadOnlyPaths=
|
|
RestrictAddressFamilies=AF_INET AF_INET6
|
|
RestrictNamespaces=true
|
|
RestrictRealtime=true
|
|
RestrictSUIDSGID=true
|
|
SystemCallFilter=@system-service ~@privileged ~@resources
|
|
UMask=0077
|
|
|
|
# Consider locking down all areas of /etc which hold machine identity keys, etc
|
|
InaccessiblePaths=/etc/ssh
|
|
|
|
# If you have systemd >= 247
|
|
ProtectProc=invisible
|
|
|
|
# If you have systemd >= 248
|
|
PrivateIPC=true
|
|
|
|
# Optional: writable directory for JetStream.
|
|
# See also: Unit.ConditionPathIsMountPoint
|
|
ReadWritePaths=/var/lib/nats
|
|
|
|
# Optional: resource control.
|
|
# Replace weights by values that make sense for your situation.
|
|
# For a list of all options see:
|
|
# https://www.freedesktop.org/software/systemd/man/systemd.resource-control.html
|
|
#CPUAccounting=true
|
|
#CPUWeight=100 # of 10000
|
|
#IOAccounting=true
|
|
#IOWeight=100 # of 10000
|
|
#MemoryAccounting=true
|
|
#MemoryMax=1GB
|
|
#IPAccounting=true
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
# If you install this service as nats-server.service and want 'nats'
|
|
# to work as an alias, then uncomment this next line:
|
|
#Alias=nats.service
|