Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support mongodb 6.x.x and later #1349

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/plugins/mongo/assets/templates/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ elaspsed=0
while [[ true ]]; do
sleep 1
elaspsed=$((elaspsed+1))
sudo docker exec mongodb mongo --eval \
sudo docker exec mongodb <%= mongoshCmd %> --eval \
'try {var c = rs.config();} catch (e){} if (c && c.members[0].host === "127.0.0.1:27017") { c.members[0].host = "mongodb:27017"; rs.reconfig(c); } else { rs.initiate({_id: "meteor", members: [{_id: 0, host: "mongodb:27017"}]}) }' \
&& exit 0

Expand Down
5 changes: 3 additions & 2 deletions src/plugins/mongo/command-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export function setup(api) {
dest: '/opt/mongodb/mongo-start-new.sh',
vars: {
mongoVersion: mongoConfig.version,
mongoshCmd: mongoConfig.version.split(".")[0] > 5 ? "mongosh" : "mongo",
mongoDbDir: '/var/lib/mongodb'
}
});
Expand Down Expand Up @@ -116,7 +117,7 @@ export function shell(api) {

const conn = new Client();
conn.on('ready', () => {
conn.exec(`docker exec -it mongodb mongo ${dbName}`, {
conn.exec(`docker exec -it mongodb ${config.mongo.version.split(".")[0] > 5 ? "mongosh" : "mongo" } ${dbName}`, {
pty: true
}, (err, stream) => {
if (err) {
Expand Down Expand Up @@ -160,7 +161,7 @@ export async function status(api) {
output: mongoStatus
} = await api.runSSHCommand(
server,
`docker exec mongodb mongo --eval ${mongoCommand} --quiet`
`docker exec mongodb ${config.mongo.version.split(".")[0] > 5 ? "mongosh" : "mongo" } --eval ${mongoCommand} --quiet`
);

try {
Expand Down