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

Error after reboot Pi #23

Closed
JerryEnt opened this issue Nov 15, 2020 · 22 comments
Closed

Error after reboot Pi #23

JerryEnt opened this issue Nov 15, 2020 · 22 comments

Comments

@JerryEnt
Copy link

JerryEnt commented Nov 15, 2020

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
Copy link
Owner

dhermanns commented Nov 15, 2020 via email

@JerryEnt
Copy link
Author

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
Copy link
Author

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
Copy link
Owner

dhermanns commented Nov 15, 2020 via email

@JerryEnt
Copy link
Author

JerryEnt commented Nov 15, 2020

I will make a new image

@dhermanns
Copy link
Owner

dhermanns commented Nov 15, 2020 via email

@JerryEnt
Copy link
Author

Thank you for the help!

@dhermanns
Copy link
Owner

dhermanns commented Nov 16, 2020 via email

@Antonia-place
Copy link

Antonia-place commented Nov 28, 2020

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
Copy link
Owner

dhermanns commented Nov 28, 2020 via email

@Antonia-place
Copy link

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

@dhermanns
Copy link
Owner

dhermanns commented Nov 28, 2020 via email

@Antonia-place
Copy link

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
Copy link

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
Copy link
Owner

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
Copy link
Contributor

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
Copy link
Owner

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
Copy link
Contributor

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
Copy link
Owner

Did you try the —repair option?

@dassystem
Copy link
Contributor

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
Copy link
Owner

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
Copy link
Owner

And this is how you do it inside a container:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants