Should I put my systemd [Install] section in my .path file or my .service file?

Table of Contents

Configuring systemd to redeploy my service when I commit a new source .jar file, I have a path file that goes along with the service and uses a PathChanged directive. The [Install] section should be in the path file, not the service file, but I notice this makes “systemctl enable MYAPP” impossible. It turns out that enable MYAPP assumes you mean MYAPP.service, so you actually just do systemctl enable MYAPP.path and you’re set.

[Unit]
Wants=myapp.service

[Path]
PathChanged=/srv/webapps/myapp/myapp.jar

[Install]
WantedBy=multi-user.target

Resources

Tory Anderson avatar
Tory Anderson
Web App Engineer, Digital Humanist, Researcher, Computer Psychologist