jbrohan
Posts: 12
Joined: Tue Oct 23, 2012 6:25 pm

Automatically update project onto many headless pi

Tue Jun 12, 2018 11:37 am

Hello
I have an application to monitor the health of a paraplegic. It includes a load cell and a moisture meter. I hope to distribute it widely.

The project is implemented in a headless pi which runs without intervention. The monitoring display is on the Android phone of the person who cares for the paraplegic person. The people involved do not have the skills or interest to execute complicated terminal commands, and I would prefer to do the updates automatically as part of the daily reboot.

There is plenty of documentation on updating the libraries like Flask or Bluez but little about updating the python code that I wrote and even the /etc/rc.local which launches the project. The pi is connected to the house internet.

User avatar
allfox
Posts: 452
Joined: Sat Jun 22, 2013 1:36 pm
Location: Guang Dong, China

Re: Automatically update project onto many headless pi

Tue Jun 12, 2018 11:45 am

I remember there are platform program which let you update those IOT Pi on the air.

They overwrite the whole image when update.
They load the image into memory before execute it, so you could cut the power anytime.

But I can't recall the name!

Heater
Posts: 15949
Joined: Tue Jul 17, 2012 3:02 pm

Re: Automatically update project onto many headless pi

Tue Jun 12, 2018 12:03 pm

You could use the services of resin.io https://resin.io/

Build and test your code, commit it to your git repository, push it to resin.io and it gets deployed on all your Pi. Easy.

Or you could use the services of dataplicity https://www.dataplicity.com/ to get a login to your Pi over the web, then manually pull and install the new code from your git repository.

Or you could build something like that yourself.
Memory in C++ is a leaky abstraction .

jbrohan
Posts: 12
Joined: Tue Oct 23, 2012 6:25 pm

Re: Automatically update project onto many headless pi

Tue Jun 12, 2018 12:37 pm

resin.io seems to be an entire operating system. I like to stick with the commonest OS.
I'll use the git approach. Thank you (and the others for kind help). I force a reboot every 24 h so that I can easily fit in an update into the rc.local.
John


tpyo kingg
Posts: 809
Joined: Mon Apr 09, 2018 5:26 pm
Location: N. Finland

Re: Automatically update project onto many headless pi

Tue Jun 12, 2018 12:43 pm

One way would be to roll your project into a package and set up a central repository from which it can be distributed. That is a bit of overhead but would allow it to be easily updated.

Another option would be to set up something with Ansible and push out the changes that way. If you can type it manually, you can script it, and if you can script it you can push it to the remote machines with Ansible.

Heater
Posts: 15949
Joined: Tue Jul 17, 2012 3:02 pm

Re: Automatically update project onto many headless pi

Tue Jun 12, 2018 12:54 pm

jbrohan,
I force a reboot every 24 h so that I can easily fit in an update into the rc.local.
What you will find is that one day the Pi does not boot and you have to run out and fix it. For any of a bunch of reasons I won't go into here.

To make this a reliable remote system I suggest making your root file system read only. That way it can never get corrupted.

Keep your application on a USB stick or such so that it can be overwritten with updates.

I'd also want to enable the hardware watchdog incase the whole OS crashes out for some odd reason. The watchdog will reboot the machine.

Resin does indeed give you an entire OS configured to get updates for your application. The application runs in a "container" so that it cannot mess with the underlying OS. It's a neat solution. Not sure if the OS image they give is based on Raspbian or not.
Memory in C++ is a leaky abstraction .

User avatar
bensimmo
Posts: 4621
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Automatically update project onto many headless pi

Tue Jun 12, 2018 2:29 pm

Why reboot, why not just schedule (Cron) a lookup to see if there is anything to update.
Only then rabbit if it needs a reboot?

I'm sure most python programs can be stopped, updated and then run without any need to reboot.

Heater
Posts: 15949
Joined: Tue Jul 17, 2012 3:02 pm

Re: Automatically update project onto many headless pi

Tue Jun 12, 2018 2:33 pm

I'm sure post programs, in whatever language, can be updated before stopping and restarting them.
Memory in C++ is a leaky abstraction .

Return to “General discussion”