A Plugins module is designed to work in Cellframe Node. Classes and methods of this module can only be used in plugins launched via Celframe Node. The module includes the following class:
In order to enable the launch of plugins in the CellFrame Node, it is necessary to uncomment the lines in the /opt/cellframe-node/etc/cellframe-node.cfg file. The lines in the file should look like this:
# Plugins
[plugins]
# Load Python-based plugins
py_load=true
# Path to Pyhon-based plugins
py_path=/opt/cellframe-node/var/plugins
The true
value of the py_load
key means that plugins will be loaded when the СellFrame Node is started. The value of the py_path
key is a path to the plugin directories. All directories with plugins should be located in this directory.
The plugin is a directory with a name that matches the name of the plugin. The plugin files are placed in this directory. The manifest file and the python script file or files must be placed in the directory. For example, explorer plugins consists of the /explorer directory and the /explorer/explorer.py and the /explorer/manifest.json files inside this directory.
The manifest file must have a name manifest.json. The manifest file must be in JSON format. For example:
{
"name": "explorer",
"version": "1.0",
"author": "DEMLABS (C) 2021",
"dependencies": [],
"description": "This plugin does the work of the backend for the blockchain explorer."
}
The name
, version
, author
and description
keys must have a string values. The name
value must match the name of the plugin and the name of the directory. The version
and author
values specifie the plugin version and plugin author. The dependencies
key must have a array value which contains strings with plugin names. If the specified plugins are not installed, then this plugin will not be launched. The description
value specifies a short description.
The plugin can include one or more python scripts. One of them should be the main one from which the plugin starts running. The name of the main python script must match the value of the "name"
key in the manifest.json file. The main script should сontain init
and deinit
(not necessary) functions that are called when the plugin starts and when it finishes, respectively. These functions do not accept any arguments.
To run the installed plugins, you need to start or restart the cellframe-node service. When starting the node service, the init
functions of the python script of each plugin will be called. When finishing the node service, the deinit
functions will be called.