4

I am trying to create a new systemd unit template file that will be used to start several instances of a server program, each running out of a different directory. i.e. I need the ExecStart parameter to be different depending on the instance.

I have tried making the path to the instance be the instance name like the following. I have the following unit file /etc/systemd/system/[email protected]:

[Unit]
Description=server instance '%I'
Requires=...
Wants=...

[Service]
Type=simple
ExecStart=%I/bin/server.sh
PIDFile=%I/server.pid

[Install]
WantedBy=multi-user.target

I do a daemon-reload:

$ sudo systemctl daemon-reload

And I try to start an instance with:

$ sudo systemctl start myserver@/path/to/instance1.service

I get an error from this saying look at the status for details. So, I do:

$ sudo systemctl status myserver@/path/to/instance1.service

I see an error that the ExecStart path is not absolute:

May 17 16:04:46 myhost systemd[1]: [/etc/systemd/system/[email protected]:9] \
  Executable path is not absolute, ignoring: %I/bin/server.sh
May 17 16:04:46 myhost systemd[1]: [email protected] lacks \
  both ExecStart= and ExecStop= setting. Refusing.

Is there a way to parameterize the path to the ExecStart binary (and PIDFile)? Am I stuck making a separate unit file for every instance?

3

0

You must log in to answer this question.

Browse other questions tagged .