On a CentOS 7 server,I'm creating a new systemd service from scratch for a new service, prometheus-slurm-exporter. (It's an application that exports data from the SLURM scheduler on an HPC cluster.) By default it uses Port 8080, but since that port is already in use by another service, I've set it use Port 9090 instead. Run from the command line, the command looks like this:
/opt/prometheus-slurm-exporter/bin/prometheus-slurm-exporter --listen-address="0.0.0.0:9090"
It runs fine from the command line, but I want to create a systemd service from it, so I've created the following file, /etc/systemd/system/prometheus-slurm-exporter.service:
[Unit]
Description=SLURM Prometheus Exporter for Grafana
After=network.target syslog.target
[Service]
ExecStart=/opt/prometheus-slurm-exporter/bin/prometheus-slurm-exporter --listen-address="0.0.0.0:9090"
[Install]
WantedBy=multi-user.target
After running systemctl daemon-reload
followed by systemctl start prometheus-slurm-exporter
, the service fails, reporting an unknown port:
Sep 30 12:21:14 ada prometheus-slurm-exporter: time="2021-09-30T12:21:14-04:00" level=info msg="Starting Server: \"0.0.0.0:9090\"" source="main.go:59"
Sep 30 12:21:14 ada prometheus-slurm-exporter: time="2021-09-30T12:21:14-04:00" level=fatal msg="listen tcp: address tcp/9090\": unknown port" source="main.go:62"
Sep 30 12:21:14 ada systemd: prometheus-slurm-exporter.service: main process exited, code=exited, status=1/FAILURE
Sep 30 12:21:14 ada systemd: Unit prometheus-slurm-exporter.service entered failed state.
Sep 30 12:21:14 ada systemd: prometheus-slurm-exporter.service failed.
Why is it running from the command line but not as a systemd service, and why can't systemd recognize Port 9090?