I'm new-ish to systemd. I've got a service that's been working fine with the ExecStart
command line hard-coded. Now I'm trying to parameterize it, and I found EnvironmentFile
written up online. So I modified my service file as follows (some things obfuscated for privacy):
[Service]
Type=simple
EnvironmentFile=/etc/my-service/my-service-systemd.cfg
ExecStart=/usr/local/bin/my-service -port=$PORT -log-level=$LOG_LEVEL -creds=$CREDENTIALS_FILE
ExecStop=/bin/kill -15 $MAINPID
I checked, and the environment file /etc/my-service/my-service-systemd.cfg
is definitely there:
CREDENTIALS_FILE=/etc/my-service/my-service.pwd
LOG_LEVEL=2
PORT=443
But when I run the service, it fails, and the logs indicate that all parameters are coming in empty, i.e. the service file is not passing in values from the EnvironmentFile
.
What am I doing wrong?