Our step-by-step guide to run a custom Pareto Anywhere configuration, initiated by a simple startup script.
Learn how to create and run a script which configures Pareto Anywhere exactly to your needs.
Create the bin/pareto-anywhere-x file that reflects your specific IoT deployment.
Pareto Anywhere installed from GitHub
These instructions assume that Pareto Anywhere has been installed on the target machine by cloning the /pareto-anywhere repository.
In the bin folder of the cloned pareto-anywhere repository, create a file called pareto-anywhere-x, changing x for the name of your configuration (ex: pareto-anywhere-custom), and copy Ctrl+C and paste Ctrl+V in the following contents:
#!/usr/bin/env node const ParetoAnywhere = require('../lib/paretoanywhere.js'); const OPTIONS = {}; let pa = new ParetoAnywhere(OPTIONS);
The default script is as simple as that! Validate that it works by opening a terminal and running, from the pareto-anywhere folder, the following command: node bin/pareto-anywhere-x
, again changing x for the name of your configuration (ex: node bin/pareto-anywhere-custom).
Edit the OPTIONS in the script, as JSON, if required.
For example, to disable CORS, specify the OPTIONS as follows:
const OPTIONS = { useCors: false };
Edit the script to add optional modules, if required.
For example, to add HCI input functionality using the /barnowl-hci module, add the highlighted lines below.
#!/usr/bin/env node const ParetoAnywhere = require('../lib/paretoanywhere.js'); const OPTIONS = {}; // ----- Exit gracefully if the optional dependency is not found ----- let BarnowlHci; try { BarnowlHci = require('barnowl-hci'); } catch(err) { console.log('This script requires barnowl-hci. Install with:'); console.log('\r\n "npm install barnowl-hci"\r\n'); return console.log('and then run this script again.'); } // ------------------------------------------------------------------- let pa = new ParetoAnywhere(OPTIONS); // Add the HCI interface with the given options const BARNOWL_HCI_OPTIONS = {}; pa.barnowl.addListener(BarnowlHci, {}, BarnowlHci.SocketListener, BARNOWL_HCI_OPTIONS);
For example, to add logfile output functionality using the /barnacles-logfile module, add the highlighted lines below.
#!/usr/bin/env node const ParetoAnywhere = require('../lib/paretoanywhere.js'); const OPTIONS = {}; // ----- Exit gracefully if the optional dependency is not found ----- let BarnaclesLogfile; try { BarnaclesLogfile = require('barnacles-logfile'); } catch(err) { console.log('This script requires barnacles-logfile. Install with:'); console.log('\r\n "npm install barnacles-logfile"\r\n'); return console.log('and then run this script again.'); } // ------------------------------------------------------------------- let pa = new ParetoAnywhere(OPTIONS); // Add the Logfile interface with the given options const BARNACLES_LOGFILE_OPTIONS = {}; pa.barnacles.addInterface(BarnaclesLogfile, BARNACLES_LOGFILE_OPTIONS);
Modify the above, as required, to accommodate barnowl-x input interfaces (see /barnowl) and/or barnacles-x output interfaces (see /barnacles).
Validate that Pareto Anywhere runs with the specified configuration.
From the terminal, change to the pareto-anywhere folder and run the command node bin/pareto-anywhere-x
, changing the "x" to the name of your configuration. Verify that there are no errors in the console logs.
If any modules were added in Step 1 above, then it is normal to observe messages about missing modules that need to be installed: this is covered next in Part 2.
Should any modules be missing, these must be installed manually as follows.
From the terminal, in the pareto-anywhere folder, install each missing module with the command npm install module-name
, changing "module-name" for the name of the module.
Run the startup script again and verify that there are no erorrs in the console logs.
The npm install
command will update the package.json file which is under git version control. See Step 3 below for instructions on updating with a modified package.json.
In a production environment, Pareto Anywhere is normally run as a service which starts automatically on boot and restarts should any errors be encountered.
Update to the latest version of Pareto Anywhere while maintaining the custom configuration.
From the terminal, in the pareto-anywhere folder, check for updates with the command git fetch
.
If there are no updates to the master branch, skip this entire step and check again for updates in future.
Before pulling updates, first check if any git version-controlled files have been locally modified, by running git status
. Modified files will be listed under Changes not staged for commit.
Revert any locally-modified files, with the command git checkout -- filename
, changing "filename" to the actual file name. In most cases, only package.json will have changed, which can be reverted with the command git checkout -- package.json
.
Run git status
once again to confirm that there are no locally-modified files.
It is normal to see the startup script itself listed under Untracked files.
From the terminal, in the pareto-anywhere folder, update to the latest version of the code base with the command git pull origin master --recurse-submodules
.
Update any package dependencies with the command npm install
.
If any modules were added in Step 1 above, they can each be updated by again running from terminal, in the pareto-anywhere folder, the command npm install module-name
, changing "module-name" for the name of the module.
If running Pareto Anywhere in the background as a service, it may be necessary to manually restart the service to benefit from the update.
Check the console output of the startup script when restarting the service to ensure that Pareto Anywhere is indeed running.
Continue exploring our open architecture and all its applications.