question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Auto-load connectors from directory

See original GitHub issue

Related to confluentinc/cp-docker-images#460

Should add some directory in kafka-connect-base that loads .json or .properties files on start.

See MySQL container for inspiration

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:20
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
nwinklercommented, Aug 27, 2019

Thanks - this was helpful! I prefer a slightly optimized version:

 volumes:
    - $PWD/scripts:/scripts  # TODO: Create this folder ahead of time, on your host
  command: 
    - bash 
    - -c 
    - |
      /etc/confluent/docker/run & 
      echo "Waiting for Kafka Connect to start listening on kafka-connect ⏳"
      while : ; do
        curl_status=$$(curl -s -o /dev/null -w %{http_code} http://kafka-connect:8083/connectors)
        echo -e $$(date) " Kafka Connect listener HTTP state: " $$curl_status " (waiting for 200)"
        if [ $$curl_status -eq 200 ] ; then
          break
        fi
        sleep 5 
      done
      echo -e "\n--\n+> Creating Kafka Connector(s)"
      /scripts/create-connectors.sh  # Note: This script is stored externally from container
      sleep infinity

Changes over the above version:

  • Only run curl once per iteration - no need to call it a second time just for printing the status. Also only one place to change the hostname and port.
  • Check for status 200 instead of a status different than 000. I’ve had Connect return a 404 status during startup (since the HTTP port was up, but the endpoint was not deployed yet), in which case the create-connectors.sh script failed. Waiting for 200 ensures that the connectors endpoint is available.
  • Removed the netcat call - not sure what that was needed for. Looks like a leftover from a previous version of the script…

FWIW, I run this from a separate service in my Docker Compose file - the image I use is appropriate/curl:latest. That way, you don’t have to start the run command in the background…

4reactions
OneCricketeercommented, Feb 6, 2019

One alternative, as shown by @rmoff

In the compose, override the container command

  volumes:
    - $PWD/scripts:/scripts  # TODO: Create this folder ahead of time, on your host
  command: 
    - bash 
    - -c 
    - |
      /etc/confluent/docker/run & 
      echo "Waiting for Kafka Connect to start listening on kafka-connect ⏳"
      while [ $$(curl -s -o /dev/null -w %{http_code} http://kafka-connect:8083/connectors) -eq 000 ] ; do 
        echo -e $$(date) " Kafka Connect listener HTTP state: " $$(curl -s -o /dev/null -w %{http_code} http://kafka-connect:8083/connectors) " (waiting for 200)"
        sleep 5 
      done
      nc -vz kafka-connect 8083
      echo -e "\n--\n+> Creating Kafka Connector(s)"
      /scripts/create-connectors.sh  # Note: This script is stored externally from container
      sleep infinity
Read more comments on GitHub >

github_iconTop Results From Across the Web

Developing a Connector - IBM
All Tivoli® Directory Integrator Connectors implement the " com.ibm.di.connector ... it will automatically load the new Connector and make it ready for use....
Read more >
Autoload classes from different folders - php - Stack Overflow
This autoloader is a direct 1:1 mapping of class name to directory structure; the namespace is the directory path and the class name...
Read more >
What is Auto Loader? | Databricks on AWS
Auto Loader provides a Structured Streaming source called cloudFiles . Given an input directory path on the cloud file storage, the cloudFiles ...
Read more >
Databricks Autoloader: Data Ingestion Simplified 101 - Learn
cloudFiles.allowOverwrites: With the default value set as true, this decides whether to permit input directory file changes to overwrite ...
Read more >
Why isn't the scripts in my autoload folder being executed in ...
I assumed "autoload" meant that the script would be loaded on startup, which is exactly what the plugin folder is for. As for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found