0

I am with CentOS 7, and I want to start Kafka standalone producer (File Connector) as a service. The command is:

/opt/kafka/bin/connect-standalone.sh /opt/kafka/config/connect-standalone.properties /opt/kafka/config/connect-file-source.properties

And, obviously, it has no stop command. Normally, I just Ctrl+C to stop it as a foreground process.

But when I test, I found very tedious to open several terminal console session to run several processes (Zookeeper, Kafka server, Kafka producer, Storm jar, etc.) so I change Zookeeper and Kafka server as service, which have their stop script. But in this case, no.

I tried systemctl start kafka-producer and systemctl stop kafka-producer, but the service entered failed status, and is not stopped. I had to delete the service, reload the daemon, and switch to manual again.

kafka-producer.service:

[Unit]
Description=Kafka Producer
After=network.target

[Service]
Type=simple
ExecStart=/opt/kafka/bin/connect-standalone.sh /opt/kafka/config/connect-standalone.properties /opt/kafka/config/connect-file-source.properties
Restart=on-abort

[Install]
WantedBy=default.target

Anyway to manipulate a service without ExecStop command?

2 Answers 2

1

If you normally stop the process with CTRL+C from your shell, a SIGINT (interrupt signal) is sent to the process. (see man signal)

When systemd tries to stop a process without ExecStop= it sends a KillSignal= which defaults to SIGTERM (terminate signal), waits for a response from the process, and if it fails to stop within a deadline, systemd sends a SIGKILL which simply forcefully ends the process. systemd's behaviour can be modified with KillSignal= (see man systemd.kill).

In your case, I would try adding KillSignal=SIGINT to emulate the CTRL+C you usually use in the shell. You know your process catches and responds to this signal, but we don't know how it responds to SIGTERM.

[Service]
Type=simple
ExecStart=/opt/kafka/bin/connect-standalone.sh /opt/kafka/config/connect-standalone.properties /opt/kafka/config/connect-file-source.properties
KillSignal=SIGINT
Restart=on-abort
0

Having HDP 2.6.4 with Kafka 0.10.1 installed, the script reported

/usr/hdp/2.6.4.0-91/kafka/bin$ ./connect-standalone.sh
USAGE: ./connect-standalone.sh [-daemon] connect-standalone.properties

a property to run as daemon by using the option -daemon.

Would this something feasible for you?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .