Update any application binary with this launcher!

Recently, I was working on a software updater for my project and I found that there is no easy way for OTA update that is ready to use and work cross platform. So I decided to write one that is so universal, it works on all kind of application binaries…


This content originally appeared on DEV Community and was authored by Toby Chui

Recently, I was working on a software updater for my project and I found that there is no easy way for OTA update that is ready to use and work cross platform. So I decided to write one that is so universal, it works on all kind of application binaries or even interpreted languages, which I later called it the "Automatic Update Launcher"

GitHub logo tobychui / Automatic-Update-Launcher

A general purpose updater for updating program binaries when update folder exists

Automatic Update Launcher

A general purpose updater for updating (web) applications server when update folder exists

What is this?

The Automatic update launcher only do one simple task, which is to upgrade your application to the latest version if it finds a later version of such application in the ./updates folder.

Its logic basically goes like this

  1. If updates/ folder exists
    1. Backup the old application files and data
    2. Copy the updates for application from updates folder to current folder
    3. Remove the updates folder
  2. Start the application
  3. Check for crash, if crash happens after update
    1. Restore the old application files and data
    2. Remove the backup folder
  4. Restart the whole process unless crash retry count > max allowed

Build

Require Go 1.17 or above

go mod tidy
go build

or just grab a copy from the release page.

Usage

Configure the launcher with launcher.json. See the example below

{
    "version":"1.0"
    "start":"helloworld*",
    "backup":

Current Implementations

❔ How normal Desktop Programs Updates

Most desktop applications will use some kind of updater to update the main program by start and detaching the updater and allow it to do its things. This work on most desktop platforms but it will not works with systemd where the PID of the running application is important. (i.e. cannot change or otherwise systemd will assume it is dead and try to restart it)
Image description

❔ How embedded devices do OTA updates

Embedded devices usually uses two partitions (one for current running application, the other one for writing update files to) and a bootloader to do the switching. One common example ESP8266 which some projects utilize its bootloader's feature to do OTA update via WiFi or Bluetooth.
Image description

🌟 How the Automatic Update Launcher (auLauncher) works 🌟

The auLauncher works in a much simpler way following the logic described in the following diagram.
Image description

and the configuration of each steps and file names can be changed easily in a json file located next to the launcher's executable. Here is an example for that:

{
    "version":"1.0",
    "start":"helloworld*",
    "backup": ["./*.config","./*.exe"],
    "verbal": true,
    "resp_port": 25576,
    "max_retry": 3,
    "crash_time": 3
}

All arguments that passed to the launcher is then passed through to the main binary. So you can easily slide this in between your starting script and your target binary without the need for changing anything.

❓ How do my program update itself then?

It is simple! If you program want to update itself, just download the update files to the ./updates folder and exit itself with code 0. This way, the launcher will start overwriting the application files based on the defination in the json file and the contents in the ./updates folder and restart your application with given start path.

This method works for most Go compiled application, but in theory should also work with other compiled binaries and some interpret language like python with a correct starting bash / batch script.

If you are interested to know more, or just wanna try this launcher and make your application OTA update a new features, feel free to take a look at this repo and left some comments :))

GitHub logo tobychui / Automatic-Update-Launcher

A general purpose updater for updating program binaries when update folder exists

Automatic Update Launcher

A general purpose updater for updating (web) applications server when update folder exists

What is this?

The Automatic update launcher only do one simple task, which is to upgrade your application to the latest version if it finds a later version of such application in the ./updates folder.

Its logic basically goes like this

  1. If updates/ folder exists
    1. Backup the old application files and data
    2. Copy the updates for application from updates folder to current folder
    3. Remove the updates folder
  2. Start the application
  3. Check for crash, if crash happens after update
    1. Restore the old application files and data
    2. Remove the backup folder
  4. Restart the whole process unless crash retry count > max allowed

Build

Require Go 1.17 or above

go mod tidy
go build

or just grab a copy from the release page.

Usage

Configure the launcher with launcher.json. See the example below

{
    "version":"1.0"
    "start":"helloworld*",
    "backup":


This content originally appeared on DEV Community and was authored by Toby Chui


Print Share Comment Cite Upload Translate Updates
APA

Toby Chui | Sciencx (2022-02-08T12:27:45+00:00) Update any application binary with this launcher!. Retrieved from https://www.scien.cx/2022/02/08/update-any-application-binary-with-this-launcher/

MLA
" » Update any application binary with this launcher!." Toby Chui | Sciencx - Tuesday February 8, 2022, https://www.scien.cx/2022/02/08/update-any-application-binary-with-this-launcher/
HARVARD
Toby Chui | Sciencx Tuesday February 8, 2022 » Update any application binary with this launcher!., viewed ,<https://www.scien.cx/2022/02/08/update-any-application-binary-with-this-launcher/>
VANCOUVER
Toby Chui | Sciencx - » Update any application binary with this launcher!. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/02/08/update-any-application-binary-with-this-launcher/
CHICAGO
" » Update any application binary with this launcher!." Toby Chui | Sciencx - Accessed . https://www.scien.cx/2022/02/08/update-any-application-binary-with-this-launcher/
IEEE
" » Update any application binary with this launcher!." Toby Chui | Sciencx [Online]. Available: https://www.scien.cx/2022/02/08/update-any-application-binary-with-this-launcher/. [Accessed: ]
rf:citation
» Update any application binary with this launcher! | Toby Chui | Sciencx | https://www.scien.cx/2022/02/08/update-any-application-binary-with-this-launcher/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.