Sergey
Sergey

Reputation: 199

Why systemd dont restart service?

Pls help. I have such Unit:

[Unit]
Description=Kafka_obed_exporter
Wants=network-online.target
After=network-online.target
After=kafka.service
Requires=kafka.service

[Service]
User=kafka_exporter
Group=kafka_exporter
Type=simple
ExecStart=/usr/local/bin/kafka_exporter --kafka.server=1.1.29.3:9092 --web.listen-address=1.1.29.2:9500
restart=always
RestartSec=10s
[Install]
WantedBy=multi-user.target

when i`m reboot server this unit try start only once and after this - fail with error:

kafka_exporter.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
kafka_exporter.service: Failed with result 'exit-code'.

i know reason why its fail - other kafka node didnt start yet, when i manually restart unit - it started fine. My question is why systemd doesnt restart this unit ? as you can see im use options Restart=always, i think systemd will try restart this unit if it not started yet. In systemd log im:

Dec 28 09:05:29 audmain systemd[1]: Started Apache Zookeeper.
Dec 28 09:05:29 audmain systemd[1]: Started Apache Kafka.
Dec 28 09:05:29 audmain systemd[1]: Started Kafka_obed_exporter.
Dec 28 09:05:29 audmain systemd[1]: Starting Network Time Service...
.......
.......
Dec 28 09:05:36 audmain systemd[1]: kafka_exporter.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Dec 28 09:05:36 audmain systemd[1]: kafka_exporter.service: Failed with result 'exit-code'.

and nothing else.

Upvotes: 0

Views: 1151

Answers (1)

maxy
maxy

Reputation: 5457

It does not restart because you wrote restart=always instead of Restart=always. Things on unix/linux are cases-sensitive.

Also, managing unit dependencies is the main business of systemd. You can tell it to start an unit after another unit. See the digitalocean.com tutorial or man systemd.unit.

Upvotes: 2

Related Questions