Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Require any instance of a template

Is it possible to tell my unit file to wait for any instance (unknown instance name) of a template unit file?

Something like this: After=template@*.service

Example:

I have this template file ([email protected]):

[Unit]
Description=TemplateFile
After=network.target

[Service]
Type=idle
ExecStart=/bin/sh -c '${JBOSS_HOME}/bin/standalone.sh ${JBOSS_START_OPTS}'
ExecStop=/bin/sh -c '${JBOSS_HOME}/bin/jboss-cli.sh ${JBOSS_STOP_OPTS}'

[Install]
WantedBy=multi-user.target

And i have this unit file (other.service):

[Unit]
Description=Other
After=network.target
#Requires=template@[a-zA-Z0-9]*.service

[Service]
Type=idle
Environment=DISPLAY=:0
ExecStart=/usr/bin/gedit
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

I want the other.service unit only to run when at least 1 instance of [email protected] is running

like image 817
Daniel Avatar asked Nov 08 '22 17:11

Daniel


1 Answers

You have to make the instantiated unit part of a custom target.. then require the target in other.service.

like image 135
Cristian Rodriguez Avatar answered Dec 06 '22 18:12

Cristian Rodriguez