Score:0

systemd service reports "unknown port"

fr flag

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?

AlexAvardo avatar
fr flag
Try `--listen-address=:9090`
Score:0
mx flag

Old but answering in case anyone else hits this - you can pass command line arguments but quoting is not as expected: https://github.com/systemd/systemd/issues/624. Without quotes e.g. this works fine:

ExecStart=/usr/local/bin/prometheus-slurm-exporter --listen-address=0.0.0.0:9341
Score:0
fr flag

I've answered my own question. It seems you can't pass command line arguments to ExecStart. Instead, I need to use

EnvironmentFile=-/etc/default/prometheus-slurm-exporter
ExecStart=/opt/prometheus-slurm-exporter/bin/prometheus-slurm-exporter $OPTIONS

And in the environment file, I have

OPTIONS=--listen-address="0.0.0.0:9090"

Works fine now.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.