Arrigo Local Custom services
Arrigo Local supports custom services. A service is a program maintained by the Process Monitor PM2 wich is used for runtime services in Arrigo Local.
Setup
All project service definitions should be defined in a service template snippet file. All definition files are located in Proj:Arrigo/pm2/snippets
folder. The folder does not exist by default. Create it if needed.
Arrigo Local life cycle
Attach project
Following steps are executed when attaching a project.
- The products template service definition snippets are read.
- The projects template service definition snippets are read.
- Macros are applied.
- The result is copied to `%Programdata%/Arrigo/Arrigo Local/pm2/ecosystem.config.js.
- The command
pm2 start ecosystem.config.js
is executed. - The command
pm2 save
is executed to save the attached state between machine restarts.
Detach project
- The command
pm2 stop all
is executed. - The command
pm2 delete all
is executed.
Macros
The service definitions supports a set of macros, which can be used for project/application specific values.
Global environment constant
In each snippet, the global constant environment
is present. This constant contains the PROJECTPATH
and the ACCOUNT
environment variables with the correct values for the current attach action. Use this to simplify your service definition.
%ARRIGOPROGRAMFILES%
A macro for root installation folder for Arrigo Local. Same as %PROGRAMDATA%/Arrigo/Arrigo Local
.
%REGINPROGRAMFILES%
A macro for root installation folder for Arrigo Local. Same as %PROGRAMDATA%/Arrigo/Arrigo Local
.
%ACCOUNT%
A macro which fectches the account entry in the Proj:Arrigo/BMS/accountsettings.json
file.
%PROJECTPATH%
A macro for the absolute path to the project folder being attached to Arrigo Local
%KEY_[serviceName]%
A macro wich value is generated as a service key. This key value is used as authToken for WAMP authentication. Each entry of this macro generates a new key. The [serviceName]
value is used as authToken service name identifier.
PM2 service configurations
We strongly recommend to read PM2 ecosystem.config.js documentation. Arrigo Local should support all settings supported by PM2. Read the documentation here.
The service definition file can contain many apps. Separate them with a comma.
They can also be defined in its own snippet file next to each other in the snippets
directory.
All examples with [xyz]
should be read as replacement values for the service definition.
[serviceName]
should be the name of the custom service. use lower case with dashes, for examplemaintenance-script
,backup-folder-task
or `web-
Production service definition
Template example | |
---|---|
Development service definition
Template example | |
---|---|
Service definition scheduled task
If the script is some kind of maintenance script or temporary script which should trig once, repeated on interval or on date, week, month, etc, the capability of cron
scheduling is very userful. Ensure that your script really is a one shot and can not hang. View this nice cron editor to make the optimal cron expression for scheduling and read about the syntax and macro support here
Template example | |
---|---|
Tip
Instead of specify the script in the script
attribute, it is possible to run any command. For example xcopy folderA folderBackup
.