How to extend the execution environment of code blocks
By default, in HAP the execution environment for code blocks is Node.js (10.18) and Python (3.6). Starting from v5.1, HAP will support the extension of more execution environment.
Currently, in addition to providing the default mirror: nocoly/hap-command:node1018-python36
There is also a relatively newer mirror available: nocoly/hap-command:node2011-python312
Considering compatibility issues, it supports switching between multiple versions or completely switching to the new version.
For extending dependencies of code blocks, view how to extend the dependencies of code blocks for more details. Just adjust the corresponding paths: change python3.6
to python3.12
, and node-10.18.0
to node-20.11
.
- Multi-version Mode
- New Version
-
- Download the mirror (Offline Package)
docker pull nocoly/hap-command:node2011-python312
-
Modify the configuration file by adding the following configuration
commandv2:
image: nocoly/hap-command:node2011-python312
environment:
<<: *app-environment -
Create a configuration file for extending code block services, such as:
/data/hap/script/volume/workflow/application-www-ext.properties
, with the following content:md.grpc.client.MDCommandService[0].address=static://commandv2:9098
md.grpc.client.MDCommandService[0].nodeVersion=20.11
md.grpc.client.MDCommandService[0].pythonVersion=3.12 -
Mount the configuration file by adding the following configuration to the volumes of the app service:
volumes:
- ./volume/workflow/application-www-ext.properties:/usr/local/MDPrivateDeployment/workflow/application-www-ext.properties
- ./volume/workflow/application-www-ext.properties:/usr/local/MDPrivateDeployment/workflowconsumer/application-www-ext.properties
- ./volume/workflow/application-www-ext.properties:/usr/local/MDPrivateDeployment/workflowintegration/application-www-ext.properties -
Restart the service
Note: In this mode, there may be compatibility issues with history code blocks. If the risk is uncontrollable, it is not recommended to switch directly.
-
Download the mirror (Offline Package)
docker pull nocoly/hap-command:node2011-python312
-
Modify the configuration file by changing the version number of the mirror corresponding to the command service to
node2011-python312
-
Restart the service