ikhvjs
ikhvjs

Reputation: 5977

How to stop a Kafka Connector running in daemon mode?

I am currently start a kafka Connector in --daemon mode below:

bin/connect-standalone.sh -daemon \
/kafka/config/connect-standalone.properties \
/kafka/config/custom-connector.properties

How do I stop this connector process gracefully?

I am currenlty using top command to locate a java process and use kill -15 pid to stop it. I found this quite not practical because I cannot specify the connector by some properties to stop it.

Is there any way to stop a kafka connector in a way like executing a command below? Or any better alternatives?

kafka/bin/kafka-connect-stop.sh \
/kafka/config/connect-standalone.properties

Upvotes: 0

Views: 1353

Answers (2)

ikhvjs
ikhvjs

Reputation: 5977

Thanks @OneCricketeer's answer.

I wrap my command using systemd script below.

Create a kafka-connector.servce file in /etc/systemd/system as below

[Unit]
Description=Kafka Connector

[Service]
User=root
Type=simple
ExecStart=/bin/sh -c "/kafka/bin/connect-standalone.sh /kafka/config/connect-standalone.properties /kafka/config/my-connector.properties"

Start the kafka connector using

sudo systemctl start kafka-connector

Stop the kafka connector using

sudo systemctl stop kafka-connector

Check the status of the kafka connector using

sudo systemctl status kafka-connector

Upvotes: 2

OneCricketeer
OneCricketeer

Reputation: 191874

To stop a connector, and not the worker, use PUT /connectors/{connector}/pause REST API endpoint.

https://kafka.apache.org/documentation/#connect_rest

Otherwise, yes, to stop the worker, you can use kill, or you can wrap it in SystemD script, and use systemctl stop to do the same.

Upvotes: 1

Related Questions