Systemd Service – Defining for SAP or Other Applications

linuxredhatsapservicesystemd

I have issues to configure a systemd service for starting and stopping SAP (or any other appliaction).
I am new to configuring systemd services and please have mercy asking "stupid" questions.

What I want/plan:

The appliaction in this case SAP is installed on local disks mounted in /local/hana/H01 and /local/hana/H01/DB; these are filesystems, which is mounted by fstab.

There is a script that starts SAP which is located in /local/hana/H01/bin/hana. If you call this script with parameter 'start' it will start SAP or with 'stop' it will terminate SAP. This script will terminate after SAP is started, but SAP processes will remain online.

There is an additional NIC configured for this SAP instance eth0:1; SAP should start after that NIC is available.
SAP admins find it convenient to login via ssh to a host to check issues, so if SAP doesn't shut down they want to connect via ssh to check; sshd should not terminate before SAP/Appliaction is down.

/local/hana/H01/bin/hana (or any other appliaction script) will start commands with timeout script to prevent a lock.

I used to use the init.d framework and used runlevel 4 to start my appliactions late in the boot process.

I have created a service configuration, wich I re-used from an existing service, so I don't understand all the options and dependencies yet. Do I need these runlevel?.target dependencies? It was in the sample file.

[Unit]
Description=System Resources for SAP HANA H01
Requires=local-fs.target
After=local-fs.target
Before=runlevel2.target
Before=runlevel3.target
Before=runlevel4.target
Before=runlevel5.target
Before=shutdown.target
Requires=network.target
After=network-online.target
After=network.service
After=sshd.service
After=local-fs.target
Conflicts=shutdown.target reboot.target
 
[Service]
Type=forking
Restart=no
StandardOutput=syslog
StandardError=syslog+console
TimeoutSec=0
IgnoreSIGPIPE=no
KillMode=process
RemainAfterExit=yes
ExecStart=/local/hana/H01/bin/hana start
ExecStop=/local/hana/H01/bin/hana stop
 
[Install]
WantedBy=multi-user.target

Did I miss anything? too much? Any suggestions on what I should add or drop?

Thanks
Fran

Best Answer

To summarize comments:

Keep it simple!

[Unit]
Description=System Resources for SAP HANA H01
Requisite=network-online.target
After=network-online.target
 
[Service]
Type=forking
Restart=no
ExecStart=/local/hana/H01/bin/hana start
ExecStop=/local/hana/H01/bin/hana stop
 
[Install]
WantedBy=multi-user.target

Should do as a start, and iterate from there as needed. More examples: the man pages

Updated 2024-03-19 - edited to add Requisite, reasons being noted here on SF