pull/2196/head
skiffer-git 7 months ago
parent 42332cdd26
commit 843a704c6f

@ -12,16 +12,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# Wait for Kafka to be ready # Wait for Kafka to be ready
KAFKA_SERVER=localhost:9092 KAFKA_SERVER=localhost:9092
MAX_ATTEMPTS=300 MAX_ATTEMPTS=300
attempt_num=1 attempt_num=1
echo "Waiting for Kafka to be ready..." echo "Waiting for Kafka to be ready..."
until /opt/bitnami/kafka/bin/kafka-topics.sh --list --bootstrap-server $KAFKA_SERVER; do until /opt/bitnami/kafka/bin/kafka-topics.sh --list --bootstrap-server $KAFKA_SERVER; do
echo "Attempt $attempt_num of $MAX_ATTEMPTS: Kafka not ready yet..." echo "Attempt $attempt_num of $MAX_ATTEMPTS: Kafka not ready yet..."
if [ $attempt_num -eq $MAX_ATTEMPTS ]; then if [ $attempt_num -eq $MAX_ATTEMPTS ]; then
@ -31,14 +26,10 @@ until /opt/bitnami/kafka/bin/kafka-topics.sh --list --bootstrap-server $KAFKA_SE
attempt_num=$((attempt_num+1)) attempt_num=$((attempt_num+1))
sleep 1 sleep 1
done done
echo "Kafka is ready. Creating topics..." echo "Kafka is ready. Creating topics..."
topics=("toRedis" "toMongo" "toPush") topics=("toRedis" "toMongo" "toPush")
partitions=8 partitions=8
replicationFactor=1 replicationFactor=1
for topic in "${topics[@]}"; do for topic in "${topics[@]}"; do
if /opt/bitnami/kafka/bin/kafka-topics.sh --create \ if /opt/bitnami/kafka/bin/kafka-topics.sh --create \
--bootstrap-server $KAFKA_SERVER \ --bootstrap-server $KAFKA_SERVER \
@ -51,5 +42,4 @@ for topic in "${topics[@]}"; do
echo "Failed to create topic $topic." echo "Failed to create topic $topic."
fi fi
done done
echo "All topics created." echo "All topics created."

@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
mongosh <<EOF mongosh <<EOF
use admin use admin
var rootUsername = '$MONGO_INITDB_ROOT_USERNAME'; var rootUsername = '$MONGO_INITDB_ROOT_USERNAME';
@ -23,7 +22,6 @@ if (authResult) {
print('Authentication failed for root user: ' + rootUsername + ' with password: ' + rootPassword); print('Authentication failed for root user: ' + rootUsername + ' with password: ' + rootPassword);
quit(1); quit(1);
} }
var dbName = '$MONGO_INITDB_DATABASE'; var dbName = '$MONGO_INITDB_DATABASE';
db = db.getSiblingDB(dbName); db = db.getSiblingDB(dbName);
var openimUsername = '$MONGO_OPENIM_USERNAME'; var openimUsername = '$MONGO_OPENIM_USERNAME';
@ -35,7 +33,6 @@ var createUserResult = db.createUser({
{ role: 'readWrite', db: dbName } { role: 'readWrite', db: dbName }
] ]
}); });
if (createUserResult.ok == 1) { if (createUserResult.ok == 1) {
print('User creation successful. User: ' + openimUsername + ', Database: ' + dbName); print('User creation successful. User: ' + openimUsername + ', Database: ' + dbName);
} else { } else {
@ -43,6 +40,3 @@ if (createUserResult.ok == 1) {
quit(1); quit(1);
} }
EOF EOF

Loading…
Cancel
Save