dhermanns / rpi-nightscout

CGM Remote Monitor aka Nightscout for the Raspberry Pi 1/2.
35 stars 49 forks source link

Error after reboot Pi #23

Closed JerryEnt closed 2 years ago

JerryEnt commented 3 years ago

After rebooting the Pi I get this error:

Oops - Nightscout is having trouble

Don't panic, we can work this out! This happens to the best of us.

Check the errors below and then refer to the troubleshooting documentation. Errors occurred during startup:

Unable to connect to Mongo {"stack":"Error: MongoDB connection failed! Double check the MONGODB_URI setting in Heroku. at /home/node/app/lib/storage/mongo-storage.js:63:32 at processTicksAndRejections (internal/process/task_queues.js:97:5)","message":"MongoDB connection failed! Double check the MONGODB_URI setting in Heroku."}

Anny idea?

Before rebooting it works fine. It looks like the Mongo db is not running. How to try to start the db

dhermanns commented 3 years ago

Hi!

What does

docker ps

return?

JerryEnt notifications@github.com schrieb am So. 15. Nov. 2020 um 19:00:

After rebooting the Pi I get this error:

Oops - Nightscout is having trouble

Don't panic, we can work this out! This happens to the best of us.

Check the errors below and then refer to the troubleshooting documentation. Errors occurred during startup:

Unable to connect to Mongo {"stack":"Error: MongoDB connection failed! Double check the MONGODB_URI setting in Heroku. at /home/node/app/lib/storage/mongo-storage.js:63:32 at processTicksAndRejections (internal/process/task_queues.js:97:5)","message":"MongoDB connection failed! Double check the MONGODB_URI setting in Heroku."}

Anny idea?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/dhermanns/rpi-nightscout/issues/23, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYPBFOZ4KIYDYSX6HRRNH3SQAJMJANCNFSM4TWKTJ4Q .

JerryEnt commented 3 years ago

Got permission denied while trying to connect to the Docker daemon socket at uni x:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers /json: dial unix /var/run/docker.sock: connect: permission denied

JerryEnt commented 3 years ago

As root user:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES aae586668988 dhermanns/rpi-nightscout:latest "docker-entrypoint.s…" 2 hours ago Up 40 minutes 0.0.0.0:1337->1337/tcp rpinightscout_nightscout_1 9d1f16cfb71e dhermanns/rpi-mongo:2.6.4 "/opt/mongodb/bin/mo…" 2 hours ago Restarting (100) 22 seconds ago rpinightscout_mongo_1

dhermanns commented 3 years ago

Looks like your mongodb has a problem. If you don‘t have lots of data inside. You can simply kill and restart.

JerryEnt notifications@github.com schrieb am So. 15. Nov. 2020 um 20:21:

As root user:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES aae586668988 dhermanns/rpi-nightscout:latest "docker-entrypoint.s…" 2 hours ago Up 40 minutes 0.0.0.0:1337->1337/tcp rpinightscout_nightscout_1 9d1f16cfb71e dhermanns/rpi-mongo:2.6.4 "/opt/mongodb/bin/mo…" 2 hours ago Restarting (100) 22 seconds ago rpinightscout_mongo_1

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dhermanns/rpi-nightscout/issues/23#issuecomment-727622274, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYPBFNDBN2AIOEUNK2QRWTSQAS5HANCNFSM4TWKTJ4Q .

JerryEnt commented 3 years ago

I will make a new image

dhermanns commented 3 years ago

docker-compose down

should do the trick.

JerryEnt notifications@github.com schrieb am So. 15. Nov. 2020 um 21:38:

Restart making a image? Or kill and restart a proces?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dhermanns/rpi-nightscout/issues/23#issuecomment-727632849, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYPBFPMUKBLZ6IGOWMIFU3SQA345ANCNFSM4TWKTJ4Q .

JerryEnt commented 3 years ago

Thank you for the help!

dhermanns commented 3 years ago

Welcome ;-)

JerryEnt notifications@github.com schrieb am So. 15. Nov. 2020 um 22:14:

Thank you for the help!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dhermanns/rpi-nightscout/issues/23#issuecomment-727637930, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYPBFMMMIPQKN2NU4WSYTDSQBAETANCNFSM4TWKTJ4Q .

Antonia-place commented 3 years ago

Hello, I have the same issue like in first post. I installed all, I received data from xDrip+ application and then, I restarted my raspberry Pi device. Then, "Oops - Nightscout is having trouble" in browser and "nightscout_1 | Error connecting to MongoDB: {"name":"MongoNetworkError"} - retrying in 60 sec" in console logs.

It is any method to avoid this?

docker-compose ps

       Name                         Command               State           Ports

rpinightscout_mongo_1 /opt/mongodb/bin/mongod Up rpinightscout_nightscout_1 docker-entrypoint.sh node ... Up 0.0.0.0:1337->1337/tcp

Because, I format the sd card from RPI, I installed all and it works until first rpi reboot.

Another thing: I create the image again and then, after mofdification os docker-compose.yml file, the following error is present (in this care, RPI wasn't restarted): HypriotOS/armv7: root@black-pearl in ~/rpi-nightscout

docker-compose logs

Attaching to rpinightscout_nightscout_1, rpinightscout_mongo_1 nightscout_1 | Node version v12.19.0 is not a LTS version. Not recommended. Not supported nightscout_1 | Parsing config URL from IMPORT_CONFIG failed nightscout_1 | Checking settings nightscout_1 | Setting up new connection to MongoDB nightscout_1 | (node:1) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor. nightscout_1 | Error connecting to MongoDB: {"name":"MongoNetworkError"} - retrying in 3 sec nightscout_1 | ERROR CONNECTING TO MONGO Error: MongoDB connection failed! Double check the MONGODB_URI setting in Heroku. nightscout_1 | at /home/node/app/lib/storage/mongo-storage.js:63:32 nightscout_1 | at processTicksAndRejections (internal/process/task_queues.js:97:5) nightscout_1 | Mongo Storage system ready nightscout_1 | Security settings: INSECURE_USE_HTTP= true , SECURE_HSTS_HEADER= true nightscout_1 | Activ pe portul 1337 f996e6ef08fd nightscout_1 | Error connecting to MongoDB: {"name":"MongoNetworkError"} - retrying in 6 sec nightscout_1 | Error connecting to MongoDB: {"name":"MongoNetworkError"} - retrying in 9 sec nightscout_1 | Error connecting to MongoDB: {"name":"MongoNetworkError"} - retrying in 12 sec Exception in thread Thread-2: Traceback (most recent call last): File "/code/build/docker-compose/out00-PYZ.pyz/threading", line 552, in __bootstrap_inner File "/code/build/docker-compose/out00-PYZ.pyz/threading", line 505, in run File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.multiplexer", line 41, in _enqueue_output File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.log_printer", line 59, in _make_log_generator File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.utils", line 77, in split_buffer File "/code/build/docker-compose/out00-PYZ.pyz/docker.client", line 199, in _multiplexed_response_stream_helper File "/code/build/docker-compose/out00-PYZ.pyz/docker.client", line 143, in _get_raw_response_socket File "/code/build/docker-compose/out00-PYZ.pyz/docker.client", line 95, in _raise_for_status APIError: 409 Client Error: Conflict ("container 47da5cda06b015d536acd689b4c547e74e19398aa46b65eebcc399b219bad446 is restarting, wait until the container is running")

nightscout_1 | Error connecting to MongoDB: {"name":"MongoNetworkError"} - retrying in 15 sec nightscout_1 | Error connecting to MongoDB: {"name":"MongoNetworkError"} - retrying in 18 sec nightscout_1 | Error connecting to MongoDB: {"name":"MongoNetworkError"} - retrying in 21 sec

Thank you, Mihai

dhermanns commented 3 years ago

Hi Antonia!

This normally happens if you restart your pi without shutting it down properly. E.g. by just pulling the cord.

When i restart e.g. by

sudo shutdown now

I don‘t experience this.

Cu, Dirk

Antonia-place notifications@github.com schrieb am Sa. 28. Nov. 2020 um 20:54:

Hello, I have the same issue like in first post. I installed all, I received data from xDrip+ application and then, I restarted mu raspberry Pi device. Then, "Oops - Nightscout is having trouble" in brobser and "nightscout_1 | Error connecting to MongoDB: {"name":"MongoNetworkError"} - retrying in 60 sec " in console logs. It is any method to avoid this? docker-compose ps

   Name                         Command               State           Ports

rpinightscout_mongo_1 /opt/mongodb/bin/mongod Up rpinightscout_nightscout_1 docker-entrypoint.sh node ... Up 0.0.0.0:1337 ->1337/tcp

Because, I format the sd card from RPI, I installed all and it works until first rpi reboot. Thank you, Mihai

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dhermanns/rpi-nightscout/issues/23#issuecomment-735283117, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYPBFLW4UUN3OUXIPTHKRTSSFIPRANCNFSM4TWKTJ4Q .

Antonia-place commented 3 years ago

Hello Dirk, Yes, you are right. I tested now wit this command, sudo shutdown now, and everythimg works great after restart. But, in case of power failure, it is any possibility to save the data from mongo db? Because, I observed this:

I ask this in case in power failure only.

Thank you, Mihai

dhermanns commented 3 years ago

You could try to search in a mongodb forum how to repair an inconsistent MongoDB instance. Should be for sure possible.

In my case I have a simple (and cheap) universal power supply to keep the pi up and running even in case of a blackout.

Antonia-place notifications@github.com schrieb am Sa. 28. Nov. 2020 um 22:43:

Hello Dirk, Yes, you are right. I tested now wit this command, sudo shutdown now, and everythimg works great after restart. But, in case of power failure, it is any possibility to save the data from mongo db? Because, I observed this:

  • set the rpi, receive data from xDrip+, is working; power off from power supply (pull the cable off); power on the rpi: the mongo connection is not possible. In this case, I have to do that:
  • docker-compose stop
  • docker-compose rm
  • docker-compose up -d After that, everything is working, but no previous data in mongo db.

I ask this in case in power failure only.

Thank you, Mihai

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dhermanns/rpi-nightscout/issues/23#issuecomment-735294101, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYPBFMIH3NMWBEEV7GRHTDSSFVGJANCNFSM4TWKTJ4Q .

Antonia-place commented 3 years ago

Ok, I will try to search on mongo forum a solution. For power, I will try an UPS, of course. Thank you for this quick support! You done a great job with Nightscout on rpi.

Antonia-place commented 3 years ago

Hi, I have another question: where I can set connection between Nightscout and Medtronic careportal? Where is the Nightscout site on rpi?

Thank you, Mihai

dhermanns commented 3 years ago

You would like to modify the environment variables of nightscout?

Have a look here: https://github.com/dhermanns/rpi-nightscout

-modify your Nightscout Settings

Or do you want to access your Nightscout Site?

It is reachable by typing

http://:1337

dassystem commented 3 years ago

Since I wanted to raise the same issue: All my other services running in docker have no problems to boot up again (e.g. after power loss). We should improve this here.

The easiest way to restart the service manually is docker-compose restart. Didn't find a way to improve unexpected (re-)boot yet.

dhermanns commented 3 years ago

In my case docker-compose restart works find - in most cases. I would assume that in cases mongo isn't able to recover from a restart, you would have to do a mongod --repairrun.

Have a look here: https://docs.mongodb.com/manual/tutorial/recover-data-following-unexpected-shutdown/

I noticed that in some cases, mongo wasn't simple able to remove the lock file from its data directory. So simply removing that solved it for me. But a repair run would be the savest way to cure this.

Further more, I would suggest running k3s in a production environment. I have documented my setup here: https://h3rmanns.medium.com/creating-a-k3s-raspberry-pi-cluster-with-k3sup-to-fire-up-a-nightscout-backend-service-based-on-a-27c1f5727e5b

I keep the data-directory outside the mongo-image there. So you can easily remove the lock-file in case of problems after a restart. Hope that helps.

dassystem commented 3 years ago

I also have my mongo data volume outside the image (see code below), but still I get the error often enough. I still don't know how to fix this error manually.

mongo:                                                                                                           
    image: arm64v8/mongo:latest                                                                                    
    volumes:                                                                                                       
    - /my/path/nightscout/data:/data/db
dhermanns commented 3 years ago

Did you try the —repair option?

dassystem commented 3 years ago

Because it just happened to me again, I still looking for a robust way. docker-compose restart helps. Any idea how to automate that? I don't want a daily cronjob, but more like a mongo --repair somewhere inside the docker-compose.

dhermanns commented 3 years ago

Yes - that was what I meant before. Have a look here:

https://docs.mongodb.com/manual/tutorial/recover-data-following-unexpected-shutdown/

mongod --repair should do the trick.

dhermanns commented 3 years ago

And this is how you do it inside a container:

https://stackoverflow.com/questions/39270058/repair-command-in-mongodb-in-docker-container