I have this systemd file:
[Unit]
Description=something website
After=syslog.target
Requires=postgresql.service
[Service]
ExecStart=/home/my_user/my_webapp/bin/ foreground
ExecStop=/home/my_user/my_webapp/bin/ stop
Restart=on-abort
WorkingDirectory=/home/my_user/my_webapp/bin
SyslogIdentifier=my_webapp_web_app
User=my_user
[Install]
WantedBy=multi-user.target
As you can see, "my_webapp" and "my_user" are repeated many times. Is there any way to store them into variables and use the variables instead?
Best Answer
Probably the closest thing that would match your needs is using the
EnvironmentFile
option.And your new unit
You would probably want your variables set differently. I'll leave that up to you to adjust.