nightscout / nightscout-docker

docker resources for creating Nightscout boxen
38 stars 38 forks source link

Startup issues #2

Closed jareware closed 7 years ago

jareware commented 9 years ago

I'm having trouble starting the containers reliably. About 4 out of 5 times I get this:

$ docker-compose up
[...]
database_1   | 2015-10-26T20:59:14.517+0000 [conn2] Failed to authenticate admin@admin with mechanism MONGODB-CR: AuthenticationFailed UserNotFound Could not find user admin@admin
database_1   | 2015-10-26T20:59:14.517+0000 [conn3]  authenticate db: admin { authenticate: 1, user: "admin", nonce: "xxx", key: "xxx" }
database_1   | 2015-10-26T20:59:14.518+0000 [conn3] Failed to authenticate admin@admin with mechanism MONGODB-CR: AuthenticationFailed UserNotFound Could not find user admin@admin
database_1   | 2015-10-26T20:59:14.519+0000 [conn4]  authenticate db: admin { authenticate: 1, user: "admin", nonce: "xxx", key: "xxx" }
database_1   | 2015-10-26T20:59:14.519+0000 [conn4] Failed to authenticate admin@admin with mechanism MONGODB-CR: AuthenticationFailed UserNotFound Could not find user admin@admin
database_1   | 2015-10-26T20:59:14.521+0000 [conn5]  authenticate db: admin { authenticate: 1, user: "admin", nonce: "xxx", key: "xxx" }
database_1   | 2015-10-26T20:59:14.521+0000 [conn5] Failed to authenticate admin@admin with mechanism MONGODB-CR: AuthenticationFailed UserNotFound Could not find user admin@admin
database_1   | 2015-10-26T20:59:14.522+0000 [conn6]  authenticate db: admin { authenticate: 1, user: "admin", nonce: "xxx", key: "xxx" }
database_1   | 2015-10-26T20:59:14.522+0000 [conn6] Failed to authenticate admin@admin with mechanism MONGODB-CR: AuthenticationFailed UserNotFound Could not find user admin@admin
database_1   | 2015-10-26T20:59:14.525+0000 [conn2] end connection 172.17.0.84:59957 (4 connections now open)
database_1   | 2015-10-26T20:59:14.526+0000 [conn3] end connection 172.17.0.84:59958 (3 connections now open)
database_1   | 2015-10-26T20:59:14.526+0000 [conn4] end connection 172.17.0.84:59959 (2 connections now open)
database_1   | 2015-10-26T20:59:14.526+0000 [conn5] end connection 172.17.0.84:59960 (1 connection now open)
database_1   | 2015-10-26T20:59:14.527+0000 [conn6] end connection 172.17.0.84:59961 (0 connections now open)
nightscout_1 | Error connecting to MongoDB, ERROR: {"name":"MongoError","message":"auth failed","ok":0,"errmsg":"auth failed","code":18}
nightscout_1 |
nightscout_1 | /home/node/app/node_modules/mongodb/lib/mongo_client.js:445
nightscout_1 |               throw err
nightscout_1 |                     ^
nightscout_1 | MongoError: auth failed
nightscout_1 |     at Function.MongoError.create (/home/node/app/node_modules/mongodb/node_modules/mongodb-core/lib/error.js:31:11)
nightscout_1 |     at /home/node/app/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:754:66
nightscout_1 |     at Callbacks.emit (/home/node/app/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:95:3)
nightscout_1 |     at null.messageHandler (/home/node/app/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:243:23)
nightscout_1 |     at Socket.<anonymous> (/home/node/app/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:262:22)
nightscout_1 |     at Socket.emit (events.js:107:17)
nightscout_1 |     at readableAddChunk (_stream_readable.js:163:16)
nightscout_1 |     at Socket.Readable.push (_stream_readable.js:126:10)
nightscout_1 |     at TCP.onread (net.js:538:20)
nightscout_nightscout_1 exited with code 1
Gracefully stopping... (press Ctrl+C again to force)
Stopping nightscout_database_1...
Stopping nightscout_broker_1...

Then that 1 time out of 5, everything works as it should.

Ideas..?

alexpop commented 9 years ago

@jareware, I had the same problem as you. I suspect the nightscout container is trying to connect to the database before this is ready to accept connections. These's a long thread on dependencies here: https://github.com/docker/compose/issues/374

I managed to workaround this issue by starting the database first:

docker-compose start database
sleep 5
docker-compose up nightscout

Let me know if this works for you. I'll investigate a better solution soon.

jareware commented 9 years ago

I actually figured the same, so I just did a docker-compose up -d database first, waited a bit, and did the same for nightscout. :) Sorry for not reporting back, I kinda forgot...

But yeah, a few delayed retries upon initial connect would be sweet.

oskarpearson commented 7 years ago

There are merged PRs that fix this now. Please can we close this?

necroscope commented 7 years ago

The startup works for me fine each time. I have the newest code. Suggest to close.

jareware commented 7 years ago

Has worked for me too!