Device restarts on power on

raspberrypi3
docker
resinos

#1
  • Context:

Many times I have faced a really unpleasant problem. In the Dashboard, after selecting an Application which I have registered, there is the table with all the devices linked to that Application.

(I’m talking about the page which link is in the following format: https://dashboard.resin.io/apps/#{APP-ID}/devices )

Here I can see where did a device come up for the last time, that is Last Seen field. Sometimes, this field shows me a time that I do not expect to because it is supposed that the device should have been up and running at that time. Anyway, it might happen that because of the power or lost of internet connection the device goes down for a while and then it comes up again. This causes an update to the Last Seen field.

  • Problem:

When the device comes up, it makes a restart. All the previous state of the device (i.e. data) is flushed and everything under CMD command in Dockerfile runs again from the beginning.
This is a very serious problem because it leads to data loss and the device restarts when I’m not prepared to take precautions to avoid that data loss.

  • Questions:

Is there a way to prevent the restart of the device in the above scenarios, when power/internet goes down and then comes up again?
I DO NOT want my device to restart when I’m not aware about this. Ideally the device should do the restart only when I explicitly want this to happen. That is, when I do a deploy or when I press the Reboot or Restart button in the Device/Summary tab.


#4

Hi @dbeqiraj, the Last Seen field means when has the resin platform last seen the device. There are a number of things that can change the value:

  • device reboot (as you mention)
  • internet reconnection (as you mention)
  • the VPN service restarting on the device
  • the VPN server restarting on our side, and the device reconnecting

Thus when the device shows e.g. Currently online (for 2 hours), any of these following things could have happened 2 hours ago.

Now, you mention, “when the device comes up, it makes a restart”. That’s only the case of the first item in the list above, the other 3 cases there’s no restart.

What kind of situation you ended up with, when the device actually has been restarter, but you have not initiated it through the dashboard? What data are you refer to being lost? Is it some work-in-progress information of your application? Do you use docker volumes (if multicontianer) or the persistent /data directories (if on singlecontainer), to keep data between application restarts?

Also, when you say you do a deploy, your device is not restarted, the application is replaced with the new version. I

Just trying to figure out what are you experiencing, as it is not totally clear what is going on. Thanks!


#5

Hi @imrehg. Here there are some clarifications of the situation:

In my case, I have an application running in my machine. That application has a database (referred as data in the question above), also stored in that machine. When the device restarts, the database is deleted and then installed from the beginning. This means, that if the database had any data entered before the machine went down, those data will be lost.

In this context, with taking precautions I mean, that when I expect the device to make e restart, i.e. when pressing the Restart button, I can make a dump of the database which I can import it after the restart.

But, the internet connection is not always under my control. For a thousand of reasons, the connection might lost even in the mid of the night when there is no one to do the support , and if the device restarts when it is connected again to the internet, the database will be flushed. So, to be clear with data I was referring to the database, not to the /data dir.

I have this bad experience usually because of the internet connection, but sometimes even because of the power.

Is there something I can do to prevent the restart in this two scenarios?

Thank you.