Giter Site home page Giter Site logo

Comments (3)

floft avatar floft commented on August 15, 2024

Yeah, I'm not too surprised. This means it's probably not syncing to disk between the save and the power failure. This depends on the filesystem, filesystem options, etc. It also depends on how long a time period that is. I've tested power failure when using Arch Linux ARM, but I'm not sure how long I waited before killing it. Evidently it was long enough for it to sync to disk, so I didn't notice the problem.

We probably just need to call "sync" after saving the file. I found some sort of fsync in PHP. I'll look into that. (Alternatively, I could store the data in something like SQLite, which would be better for the website and crash resistance but harder to then edit via the terminal.)

from bellsystem.

1pratham avatar 1pratham commented on August 15, 2024

Is some other file also involved apart from config.xml?
I have done the following test:

  1. Make changes using the WebUI.
  2. Manually check changes are reflected in config.xml.
  3. Plug out the power source after 3-4 minutes.
  4. Start the Pi again.

Even though changes are reflected in Step 2, on starting the Pi in Step 4 the older settings are again reflected in the WebUI and config.xml.

As a temporary solution, I have added a "Restart" button in the WebUI which safely restarts the Pi. So after each proper setting save, I just press the restart button.

from bellsystem.

floft avatar floft commented on August 15, 2024

The website interface more-or-less only changes the config.xml file (though, probably some session files for login too I guess). A forced sync to disk on save should fix the problem. I added that in c695894. See if this works. I pulled the power after a few seconds after clicking "save" and all the changes stayed intact. Though, I also tried it without the "system('sync')" in the PHP code and I didn't lose any data for some reason. Maybe there's a difference in SD card write speeds between your and my cards.

Interestingly, there has been some discussion about handling proper shutdown on power failure: https://raspberrypi.stackexchange.com/questions/5372/circuit-to-safely-power-down-pi

For example, one of the UPS / batteries that was listed states "Full power management API available to Raspberry Pi OS with auto shutdown capability when running low on batteries": https://uk.pi-supply.com/products/pijuice-standard

That would be the ideal solution in general, which would keep it online during brief power failures and then allow proper shutdown when the battery is getting low. At least with my setup of bell systems though, the bell won't work when the power is out, so the Pi dying is perfectly fine as long as the filesystem doesn't get corrupted.

Let me know if the update works for you.

from bellsystem.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.