9

I have to set up a license server on a RHEL7 machine with systemd. The license server should start upon boot and load a license file from a shared disk on the network. So I need to wait for the network to start and for autofs to finish mounting NFS disks. I have this service file:

[Unit]
Description=Flexnet license server
Wants=network.target network-online.target autofs.service
After=network.target network-online.target autofs.service

[Service]
Type=forking
User=licenseuser
Group=devusers
ExecStart=/soft/flexera/glnxa64/lmgrd -c /soft/licenses/license.dat -L /home/licenseuser/license.log

# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300

[Install]
WantedBy=multi-user.target

The service starts after autofs has started but before autofs has mounted all of the disks so the license server cannot be started.

8

You should add in the following

[Unit]
RequiresMountsFor=<path required>

This will ensure the path is accessible before starting the service and also will mount it if it's not already (unless it has noauto specified). Check with your manpages (man systemd.unit) if the option is supported in your system as mine is quite bleeding edge.

  • sorry for necro, but what if this is an NFS mount and nfs hasn't yet started? Edit: answering my own question, just checked the manpage RequiresMountsFor, so it appears to work with nfs mounts too as long as they are well defined in /etc/fstab without 'noauto' – Normadize Mar 28 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.