From 651d9b3131349a190469f6cd7d14c0f21aa14d7a Mon Sep 17 00:00:00 2001 From: xuriwuyun Date: Tue, 27 Jun 2023 12:00:31 +0800 Subject: [PATCH 1/3] fix --- deploy/mongodb/scripts/replicaset-setup.tpl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/deploy/mongodb/scripts/replicaset-setup.tpl b/deploy/mongodb/scripts/replicaset-setup.tpl index a3fe507c849..cb83ed9071e 100644 --- a/deploy/mongodb/scripts/replicaset-setup.tpl +++ b/deploy/mongodb/scripts/replicaset-setup.tpl @@ -21,7 +21,7 @@ BACKUPFILE=$MONGODB_ROOT/db/mongodb.backup if [ -f $BACKUPFILE ] then mongod --bind_ip_all --port $PORT --dbpath $MONGODB_ROOT/db --directoryperdb --logpath $MONGODB_ROOT/logs/mongodb.log --logappend --pidfilepath $MONGODB_ROOT/tmp/mongodb.pid& - until mongosh --quiet --port $PORT --host $host --eval "print('peer is ready')"; do sleep 1; done + until mongosh --quiet --port $PORT --host $host --eval "print('restore process is ready')"; do sleep 1; done PID=`cat $MONGODB_ROOT/tmp/mongodb.pid` mongosh --quiet --port $PORT local --eval "db.system.replset.deleteOne({})" @@ -31,5 +31,8 @@ then wait $PID rm $BACKUPFILE fi - + am +trap "echo 'Terminating...' && kill `cat /data/mongodb/tmp/mongodb.pid`" TERM mongod --bind_ip_all --port $PORT --replSet $RPL_SET_NAME --config /etc/mongodb/mongodb.conf + until mongosh --quiet --port $PORT --host $host --eval "print('I am ready')"; do sleep 1; done + PID=`cat $MONGODB_ROOT/tmp/mongodb.pid` From da053ace52f9f671d2804ac8c06b3bd442ddf58f Mon Sep 17 00:00:00 2001 From: xuriwuyun Date: Tue, 27 Jun 2023 15:45:20 +0800 Subject: [PATCH 2/3] process signal TERM --- deploy/mongodb/scripts/replicaset-setup.tpl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/deploy/mongodb/scripts/replicaset-setup.tpl b/deploy/mongodb/scripts/replicaset-setup.tpl index cb83ed9071e..9e15f122677 100644 --- a/deploy/mongodb/scripts/replicaset-setup.tpl +++ b/deploy/mongodb/scripts/replicaset-setup.tpl @@ -31,8 +31,9 @@ then wait $PID rm $BACKUPFILE fi - am + trap "echo 'Terminating...' && kill `cat /data/mongodb/tmp/mongodb.pid`" TERM -mongod --bind_ip_all --port $PORT --replSet $RPL_SET_NAME --config /etc/mongodb/mongodb.conf - until mongosh --quiet --port $PORT --host $host --eval "print('I am ready')"; do sleep 1; done - PID=`cat $MONGODB_ROOT/tmp/mongodb.pid` +mongod --bind_ip_all --port $PORT --replSet $RPL_SET_NAME --config /etc/mongodb/mongodb.conf& +until mongosh --quiet --port $PORT --host $host --eval "print('I am ready')"; do sleep 1; done +PID=`cat $MONGODB_ROOT/tmp/mongodb.pid` +wait $PID From ced7d6cfab09ac3b4158157068cc1896b00fa27e Mon Sep 17 00:00:00 2001 From: xuriwuyun Date: Tue, 27 Jun 2023 17:29:10 +0800 Subject: [PATCH 3/3] update --- deploy/mongodb/scripts/replicaset-setup.tpl | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/deploy/mongodb/scripts/replicaset-setup.tpl b/deploy/mongodb/scripts/replicaset-setup.tpl index 9e15f122677..28fc81b29a3 100644 --- a/deploy/mongodb/scripts/replicaset-setup.tpl +++ b/deploy/mongodb/scripts/replicaset-setup.tpl @@ -32,8 +32,4 @@ then rm $BACKUPFILE fi -trap "echo 'Terminating...' && kill `cat /data/mongodb/tmp/mongodb.pid`" TERM -mongod --bind_ip_all --port $PORT --replSet $RPL_SET_NAME --config /etc/mongodb/mongodb.conf& -until mongosh --quiet --port $PORT --host $host --eval "print('I am ready')"; do sleep 1; done -PID=`cat $MONGODB_ROOT/tmp/mongodb.pid` -wait $PID +exec mongod --bind_ip_all --port $PORT --replSet $RPL_SET_NAME --config /etc/mongodb/mongodb.conf