In prior blog posts, we have discussed how a company can run the same application in the three major operating systems, Windows, MacOS, and Linux, using a single code-base. In the blog "Electron: Create a single app for Windows, Linux, and Mac" we demonstrate how one might implement a solution to this problem using the open-source technology Electron. And, while it does provide a great pathway, financial companies may find it falls short when it comes to Enterprise-level integration.
Enter the product OpenFin. It is an Electron-based platform so it provides the same abilities but also comes with features designed specifically to address those shortcomings. A high-level discussion on what the technology is all about is provided in the blog "OpenFin: electron-based runtime with real advantages for banks". Features worth noting are the centralized installation/distribution system and the inter-application bus that can talk to apps written in Java and .NET.
In this article, we provide technical details on how to run the same application discussed in the Electron post in the same three operating systems but using OpenFin. Details about the application used can be found in the blog "Simple Performance Measurement with Node.js, Electron, OpenFin and Web". The application measures latency between a node.js backend server and an HTML user interface (UI). The source code can be found here.
To begin, we first consider OpenFin’s ability to dynamically build installation executables. Currently, this is only available for Windows but the company is promising options for Mac and Linux in the near future. So, for now, we will use command line for those two systems.
We need an app.json file that is accessible from the client computer. This is analogous to the package.json file of a node/electron project as it acts as the launching point for the OpenFin runtime. But because the installation process is dynamic the file can also be – it is hosted remotely and generated at runtime when the installer calls for it. If we look at the file openFinJson.js we do exactly that:
The function createJson (host) is passed a host URL and returns the app.json string. This is served out by our node.js server as http://localhost:5000/app.json (or whatever the IP address of the machine running the node.js server is) by an expressJS route:
With this in place, we now start the node.js “server” using the command:
This will launch our web and data server to allow us to serve up the files.
Next, we have OpenFin create the openfin-install.exe by navigating to:
This will go to OpenFin’s server and tell it where to get the app.json file which is called upon when executed. The newly-created installer is sent back to the user:
Running the executable in Windows will trigger a familiar installation process:
Which creates Desktop and Start Menu icons and launches the application:
For Mac and Linux, the process is not quite as evolved – yet. As mentioned above, the company is still working on a packaging system to provide the same functionality as in Windows. Until then, we must be content with installing the node dependencies on the client machine and launching the application via command line.
The installation process is very similar for Mac and Linux since both systems are Unix-based. First step is to get node.js installed. Your favorite online search engine for your specific OS (Mac, Ubuntu, CentOS, Fedora, etc.) will yield plenty of help on how to do this.
Once node.js is available, the OpenFin command-line interface (CLI) must be installed globally. To do this, simply run the following in the terminal:
npm install openfin-cli --global
On Mac, we would see something like this:
On Linux, Ubuntu Desktop in this case, we would see this:
Now, we can run the application on the client machine by pointing the CLI to the app.json file with the following:
openfin --launch --config http://localhost:5000/app.json
On MacOS, we see the application running like this:
On Linux, we see the application running like this:
And with that we have the same application running in the three most popular operating systems all from a single code-base. Because content and deployment are all controlled by the server rolling out updates is seamless. And because of the OpenFin inter-application bus we can easily integrate with legacy application in .NET and Java allowing for a more modular approach to upgrading applications.
Interested in running the same application on all three of the major operating systems? Need to have it talk to existing infrastructure? Get in touch via the form below!