Skip to content

Commit

Permalink
Merge pull request #1349 from bessw/fix_mongo_6.x.x
Browse files Browse the repository at this point in the history
Support mongodb 6.x.x and later
  • Loading branch information
zodern authored Oct 11, 2024
2 parents f9ee3ec + 8610150 commit 86d0702
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
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",

Check failure on line 60 in src/plugins/mongo/command-handlers.js

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote

Check failure on line 60 in src/plugins/mongo/command-handlers.js

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote

Check failure on line 60 in src/plugins/mongo/command-handlers.js

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote
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}`, {

Check failure on line 120 in src/plugins/mongo/command-handlers.js

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote

Check failure on line 120 in src/plugins/mongo/command-handlers.js

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote

Check failure on line 120 in src/plugins/mongo/command-handlers.js

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote

Check failure on line 120 in src/plugins/mongo/command-handlers.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected space(s) before '}'
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`

Check failure on line 164 in src/plugins/mongo/command-handlers.js

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote

Check failure on line 164 in src/plugins/mongo/command-handlers.js

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote

Check failure on line 164 in src/plugins/mongo/command-handlers.js

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote
);

try {
Expand Down

0 comments on commit 86d0702

Please sign in to comment.