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

Cannot connect to mongodb #25

Closed
oe8bck opened this issue Jun 21, 2023 · 7 comments
Closed

Cannot connect to mongodb #25

oe8bck opened this issue Jun 21, 2023 · 7 comments
Labels
invalid This doesn't seem right

Comments

@oe8bck
Copy link

oe8bck commented Jun 21, 2023

Describe the bug
the Mongoose service is not started

To Reproduce
Steps to reproduce the behavior:

  1. docker compose start

Expected behavior
access to localhost:80 is possible

LOG-file

*** Running /etc/my_init.d/98_check_db_access.sh...
Checking can connect to mongo and redis
Using default settings from /overleaf/services/web/config/settings.defaults.js
Using settings from /etc/sharelatex/settings.js
Set UV_THREADPOOL_SIZE=16
Cannot connect to mongodb
MongooseServerSelectionError: connect ECONNREFUSED 172.17.0.1:27017
    at NativeConnection.Connection.openUri (/overleaf/services/web/node_modules/mongoose/lib/connection.js:825:32)
    at /overleaf/services/web/node_modules/mongoose/lib/index.js:411:10
    at /overleaf/services/web/node_modules/mongoose/lib/helpers/promiseOrCallback.js:41:5
    at new Promise (<anonymous>)
    at promiseOrCallback (/overleaf/services/web/node_modules/mongoose/lib/helpers/promiseOrCallback.js:40:10)
    at Mongoose._promiseOrCallback (/overleaf/services/web/node_modules/mongoose/lib/index.js:1285:10)
    at Mongoose.connect (/overleaf/services/web/node_modules/mongoose/lib/index.js:410:20)
    at Object.<anonymous> (/overleaf/services/web/app/src/infrastructure/Mongoose.js:19:36)
    at Module._compile (node:internal/modules/cjs/loader:1196:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1250:10) {
  reason: TopologyDescription {
    type: 'Unknown',
    servers: Map(1) { 'dockerhost:27017' => [ServerDescription] },
    stale: false,
    compatible: true,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    setName: null,
    maxElectionId: null,
    maxSetVersion: null,
    commonWireVersion: 0,
    logicalSessionTimeoutMinutes: null
  },
  code: undefined
}
*** /etc/my_init.d/98_check_db_access.sh failed with status
*** Killing all processes...
@tuetenk0pp
Copy link
Owner

Can you share your compose file? Please note, that docker-compose.yml in this repository is not suited for production use.

@oe8bck
Copy link
Author

oe8bck commented Jun 25, 2023 via email

@tuetenk0pp
Copy link
Owner

Sorry, GitHub does not show attached files from email. Could you upload the file via the webgui? Also, I noticed that you used docker compose start instead of the docker compose up command. Maybe that makes a difference.

@oe8bck
Copy link
Author

oe8bck commented Jun 26, 2023 via email

@tuetenk0pp
Copy link
Owner

This is related to the latest Overleaf Update and apparently not a bug. See overleaf/overleaf#1120 and the Release Notes. You can either use the Workaround from the release notes or the officially recommended method of using the Overleaf Toolkit.

@stockmind
Copy link

stockmind commented Jul 6, 2023

Edit the docker-compose file replacing mongo entry with:

   mongo:
    restart: always
    image: mongo:4.4
    container_name: mongo
    command: "--replSet overleaf"
    expose:
      - 27017
    volumes:
      - mongo_data:/data/db
    healthcheck:
      test: echo 'db.stats().ok' | mongo localhost:27017/test --quiet
      interval: 10s
      timeout: 10s
      retries: 5

  mongoinit:
    image: mongo:4.4
    # this container will exit after executing the command
    restart: "no"
    depends_on:
      mongo:
        condition: service_healthy
    entrypoint:
      [
        "mongo",
        "--host",
        "mongo:27017",
        "--eval",
        'rs.initiate({ _id: "overleaf", members: [ { _id: 0, host: "mongo:27017" } ] })',
      ]

the one time container should do the trick

@oe8bck
Copy link
Author

oe8bck commented Jul 6, 2023

Thanks, now it works! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants