End-user controlled updates

The standard deployment flow for resin.io is completely automated- meaning that when you push an application to resin.io it is built- downloaded and automatically started on every device in your fleet. This is great- it allows for the ‘git push and forget about it’ mentality- and satisfies the most common embedded use cases. However- there…

The standard deployment flow for resin.io is completely automated, meaning that when you push an application to resin.io it is built, downloaded and automatically started on every device in your fleet. This is great, it allows for the “git push and forget about it” mentality, and satisfies the most common embedded use cases.

However, there are use cases where more control is required, in cases where the developer isn’t aware of the when the device is in use, it makes sense for the end-user to have control over when an update is performed.

screent-shot

resin.io has a simple lockfile feature which allows you write a lockfile to the device to stop any new updates from occurring. The resin device agent also has a local API, which you check for pending updates. Putting these two functions together you can create a simple mechanism that allows an end-user to check for a new update and then run said update at a time of their choosing by removing or overriding the update-lock.

Locking a device from incoming updates is very simple.

sh
$ touch /data/resin-updates.lock

note: The lock must be saved to /data directory.

And over-riding a update lock is just almost as easy. All it takes is a local post request to the resin supervisor’s update endpoint with body of {"force": true}.

sh
$ curl -X POST --header "Content-Type:application/json" \
--data '{"force": true}' \
"$RESIN_SUPERVISOR_ADDRESS/v1/update?apikey=$RESIN_SUPERVISOR_API_KEY"

I’ve created a simple implementation of this in Node.js using Expressjs, socket.io and resin device URLs to forward requests from the user’s browser to the resin device agent. You can see a short demo below and a grab the code here.

Not familiar with resin.io? follow our getting started guide to learn the basics.

Any questions? Ping me(@craig-mulligan) on gitter.


Posted

in

Tags: