Skip to content

Commit

Permalink
Merge pull request #321 from craigbr/add_kafka_sleep
Browse files Browse the repository at this point in the history
Allow kafka container to stay alive after kafka exits
  • Loading branch information
mhoppal authored Nov 6, 2017
2 parents 233234a + b1634b0 commit 484eb35
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions kafka/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Several parameters can be specified using environment variables:
| `KAFKA_STACK_SIZE` | `1024k` | JVM stack size |
| `LOG_RETENTION_HOURS` | `4` | Number of hours to keep a log file |
| `LOG_ROLL_MS` | `900000` | Number of ms before a new log segment is rolled out |
| `STAY_ALIVE_ON_FAILURE` | `false` | If `true`, container stays alive for 2 hours after kafka exits |

### Log Files

Expand Down
2 changes: 1 addition & 1 deletion kafka/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repository: monasca/kafka
variants:
- tag: 0.9.0.1-2.11-1.1.5
- tag: 0.9.0.1-2.11-1.1.6
args:
KAFKA_VERSION: "0.9.0.1"
SCALA_VERSION: "2.11"
18 changes: 17 additions & 1 deletion kafka/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ ZOOKEEPER_WAIT_TIMEOUT=${ZOOKEEPER_WAIT_TIMEOUT:-"3"}
ZOOKEEPER_WAIT_DELAY=${ZOOKEEPER_WAIT_DELAY:-"10"}
ZOOKEEPER_WAIT_RETRIES=${ZOOKEEPER_WAIT_RETRIES:-"20"}

STAY_ALIVE_ON_FAILURE=${STAY_ALIVE_ON_FAILURE:-"false"}

export SERVER_LOG_LEVEL=${SERVER_LOG_LEVEL:-"INFO"}
export REQUEST_LOG_LEVEL=${REQUEST_LOG_LEVEL:-"WARN"}
export CONTROLLER_LOG_LEVEL=${CONTROLLER_LOG_LEVEL:-"INFO"}
Expand Down Expand Up @@ -103,5 +105,19 @@ if [ "$GC_LOG_ENABLED" != "true" ]; then
sed "-i.sv" -e "s/-loggc//" /kafka/bin/kafka-server-start.sh
fi

echo "Current disk space usage"
# Make this directory configurable if it becomes configurable in server.properties.j2
df /data

echo "Starting kafka..."
exec /kafka/bin/kafka-server-start.sh "$CONFIG_DEST/server.properties"
EXEC="exec"
if [ "$STAY_ALIVE_ON_FAILURE" = "true" ]; then
EXEC=""
fi
$EXEC /kafka/bin/kafka-server-start.sh "$CONFIG_DEST/server.properties"
RESULT=$?

# Keep the container alive for debugging or actions like resolving a full disk. This
# sleep will only be reached if STAY_ALIVE_ON_FAILURE is true
sleep 7200
exit $RESULT

0 comments on commit 484eb35

Please sign in to comment.