# Copyright (c) 2021, Dell Inc. or its subsidiaries.  All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# See the LICENSE file for details.
#
# This file is part of NVMe STorage Appliance Services (nvme-stas).
#

# Note that stafd can run w/o the avahi-daemon. However, if the avahi-daemon
# is present, stafd should start after it for proper process sequencing.
[Unit]
Description=@STAF_DESCRIPTION@ (@STAF_ACRONYM@)
Documentation=man:@STAFD_PROCNAME@.service(8) man:@STAFD_PROCNAME@(8)
Wants=modprobe@nvme_fabrics.service modprobe@nvme_tcp.service network.target stas-config.target
After=modprobe@nvme_fabrics.service modprobe@nvme_tcp.service network.target stas-config.target avahi-daemon.service

# Check that the nvme-tcp kernel module was previously
# loaded by checking for the presence of /dev/nvme-fabrics.
AssertPathExists=/dev/nvme-fabrics

[Service]
Type=dbus
BusName=@STAFD_DBUS_NAME@
SyslogIdentifier=@STAFD_PROCNAME@

ExecStart=/usr/bin/python3 -u @STAFD_EXECUTABLE@ --syslog
ExecReload=/bin/kill -HUP $MAINPID

# Run-time directory: /run/@STAFD_PROCNAME@
# Cache directory: /var/cache/@STAFD_PROCNAME@
RuntimeDirectory=@STAFD_PROCNAME@
CacheDirectory=@STAFD_PROCNAME@
RuntimeDirectoryPreserve=yes

[Install]
WantedBy=multi-user.target
