The bootstrap node, open ports, logs, etc. of this project can all be configured in the JSON file. This article describes all configuration items in detail and provides two examples.
You can use the command to automatically generate a JSON configuration file, and then manually add the bootstrap node to the configuration file.
If the machine to be deployed has a public IP address, that is, deploying an Input node, please use the host -init input command. Otherwise, use the host -init worker command to deploy a Worker node.
Although the list of AI projects supported by the node is also saved in this configuration file, it is recommended to use the HTTP API interface to manage it, rather than directly editing the configuration file to modify this item.
{
// Boot node list, used for node routing and discovery functions, needs to be deployed on
// a public network server, preferably with a domain name
"Bootstrap": [
"/ip4/122.99.183.54/tcp/6001/p2p/16Uiu2HAmRTpigc7jAbsLndB2xDEBMAXLb887SBEFhfdJeEJNtqRM",
"/ip4/8.219.75.114/tcp/6001/p2p/16Uiu2HAmS4CErxrmPryJbbEX2HFQbLK8r8xCA5rmzdSU59rHc9AF"
],
// Listening address for node connection communication
"Addresses": [
"/ip4/0.0.0.0/tcp/6001",
"/ip6/::/tcp/6001"
],
// API that provides HTTP services
"API": {
// Provided in the form "host:port", such as "localhost:8080", "127.0.0.1:8080"
// or "0.0.0.0:8080", where "0.0.0.0:8080" can be abbreviated as ":8080".
"Addr": "0.0.0.0:6000"
},
// The identity information of the node, which can be read and generated using the
// `host -peerkey ./peer.key` command and saved in the `./peer.key` file. Back it up and do not delete it.
// The following is just an example. Please generate and fill it out by yourself during actual deployment.
// PeerID is generated by algorithm using public key, and the program will verify whether PeerID and PrivKey match.
"Identity": {
// Node ID of the node, which is a unique ID that identifies different nodes in a distributed communication network.
"PeerID": "16Uiu2HAmJnGqxBqtWGkymSsy5WDKJY5A5NctcUduENADDptQFF4Y",
// Node’s private key
"PrivKey": "CAISINAckM6QODvCrez5I0Q3RZyo9PeV4jDeB1L71AHnSU/H"
},
// Configure node connection parameters
"Swarm": {
// Connection manager
"ConnMgr": {
// Type of connection manager
// "basic" - Basic manager with parameters such as "HighWater" "LowWater"
// "none" - Not using a connection manager
"Type": "basic",
// GracePeriod is a time duration that new connections are immune from being closed by
// the connection manager.
"GracePeriod": "60s",
// When a node using the basic connection manager reaches HighWater idle connections,
// it will close the least useful ones until it reaches LowWater idle connections.
"HighWater": 400,
"LowWater": 100
},
// Disable automatic NAT port forwarding.
// When not disabled (default), the local node asks NAT devices (e.g., routers), to open up
// an external port and forward it to the port node is running on. When this works (i.e., when
// your router supports NAT port forwarding), it makes the local node accessible from the
// public internet.
"DisableNatPortMap": false,
// Configuration options for the relay client to use relay services.
"RelayClient": {
// Enables "automatic relay user" mode for this node.
// If the node is deployed on a public server, please disable it, otherwise enable it.
"Enabled": true,
"StaticRelays": []
},
// Configuration options for the relay service that can be provided to other peers on the network
"RelayService": {
// Enables providing `/p2p-circuit` v2 relay service to other peers on the network.
// If the node is deployed on a public server, please enable it, otherwise disable it.
"Enabled": false
},
// Experimental
// Enable hole punching for NAT traversal when port forwarding is not possible. (default: disabled)
// When enabled, the local node will coordinate with the counterparty using a relayed connection,
// to upgrade to a direct connection through a NAT/firewall whenever possible. This feature
// requires Swarm.RelayClient.Enabled to be set to true.
"EnableHolePunching": false,
// If you want to help other peers to figure out if they are behind NATs, you can launch the
// server-side of AutoNAT too (RelayClient already runs the client).
// This configures the node to provide a service to peers for determining their reachability status.
// If the node is deployed on a public server, please enable it, otherwise disable it.
// This service is highly rate-limited and should not cause any performance issues.
"EnableAutoNATService": true,
// The timeout for dialing another node, including the time between dialing the original network
// connection, protocol selection, and handshake (if applicable).
// Can be set to "5s" "10s" "15s" etc. Defaults to empty (use libp2p library defaults).
"DialTimeout": ""
},
// Publish and subscribe configuration
"Pubsub": {
// Enabled by default
"Enabled": true,
// Route type, default "gossipsub"
// "floodsub" - floodsub is a basic router that simply floods messages to all connected peers.
// This router is extremely inefficient but very reliable. Suitable for small networks with few nodes.
// "gossipsub" - gossipsub is a more advanced router with mesh formation and gossip propagation.
// Suitable for large networks with many nodes.
"Router": "gossipsub",
// Use flood publishing in "gossipsub" to send messages to all peers with a score greater than publishThreshold.
"FloodPublish": true
},
// Node routing configuration
"Routing": {
// Route type, one of the following options
// "dhtclient" - Client mode, suitable for nodes behind NAT
// "dhtserver" - Server mode, suitable for nodes deployed on public network servers
// "auto" - Automatically determine client mode or server mode based on network conditions
// "none" - Not using DHT routing to discover other nodes
"Type": "dhtclient",
// The prefix of the routing protocol. Nodes with different protocols cannot establish connections.
"ProtocolPrefix": "/dbc"
},
// Application configuration
"App": {
// Log level, one of "debug"、"info"、"warn"、"error"、"panic" and "fatal"
"LogLevel": "info",
// Log file path, used to save log records generated by the program
"LogFile": "./test.log",
// Log output mode, freely combined by "stderr", "file" or "+"
// "stderr" - output to console
// "file" - Output to the file specified by "LogFile"
// "stderr+file" - Output to the console and the specified file at the same time
"LogOutput": "stderr+file",
// Pre-generated shared key, nodes with different keys cannot establish connections
"PreSharedKey": "f504f536a912a8cf7d00adacee8ed20270c5040d961d7f3da4fccbcbec0ec48a",
// The subscribed topic name, used for centralized node query services, such as querying
// the Node ID list of all nodes in the network.
// Different topic names may prevent others from querying the node you deployed.
"TopicName": "DeepBrainChain",
// The data storage folder persists the successfully connected peer information and other
// information to facilitate the node to quickly reconnect to the network when it starts.
// Please create this folder in advance and ensure that this node program has read and
// write permissions.
"Datastore": "./datastore",
// Automatic upgrade configuration
// 1. Automatically detect and download updates published in the Release of the Github project.
// 2. Automatically verify the hash value of the latest application.
// 3. Automatically stop the program when the application is idle (the number of HTTP requests and model
// requests currently being processed is 0).
// Please note: When it is determined that an upgrade is required, the program will be automatically stopped,
// but the new process will not be restarted, so please set up a daemon process similar to Systemd/pm2 yourself.
"AutoUpgrade": {
// Whether to enable automatic upgrade. If enabled, please ensure that the node's network can access github.com normally.
"Enabled": true,
// The interval of the automatic upgrade timer, which is executed once every hour by default.
"TimeInterval": "1h"
},
// Collect the heartbeat information broadcast by the node, which includes the supported
// AI projects and models.
"PeersCollect": {
// The node information will be saved to the leveldb database only if the node is located on
// a public network server and collection is enabled.
"Enabled": false,
// Heartbeat interval
"HeartbeatInterval": "180s",
// The name of the project to which the client node belongs, such as "DecentralGPT" and "SuperImage".
// This configuration item is used to deploy a dedicated client node for the AI project.
// The default value is empty, indicating a public client node. If it is not empty, this node refuses
// connections from model nodes that are not part of this project.
"ClientProject": ""
}
},
// The list of AI projects supported by the node, which can be managed using the registration/unregistration
// interface, but manual modification is not recommended.
"AIProjects": [
{
// Project name
"Project": "SuperImage",
// Model list, a project can contain multiple models
"Models": [
{
// Model name
"Model": "SuperImageAI",
// The access interface of the model is used to receive HTTP requests, run the model according to
// the prompt words and other parameters in the request, and return the generated text or images.
// This must be configured on the node that executes the AI model.
"API": "http://127.0.0.1:1088/models",
// Model type, one of the following options
// 0 - Text chat dialogue model
// 1 - Text generation picture model
// 2 - Image generation image model
"Type": 1
}
]
}
]
}This example is used for the worker node without a public IP address.
{
"Bootstrap": [
"/ip4/122.99.183.54/tcp/6001/p2p/16Uiu2HAmRTpigc7jAbsLndB2xDEBMAXLb887SBEFhfdJeEJNtqRM",
"/ip4/8.219.75.114/tcp/6001/p2p/16Uiu2HAmS4CErxrmPryJbbEX2HFQbLK8r8xCA5rmzdSU59rHc9AF"
],
"Addresses": [
"/ip4/0.0.0.0/tcp/6001",
"/ip6/::/tcp/6001"
],
"API": {
"Addr": "127.0.0.1:6000"
},
"Identity": {
"PeerID": "16Uiu2HAmJnGqxBqtWGkymSsy5WDKJY5A5NctcUduENADDptQFF4Y",
"PrivKey": "CAISINAckM6QODvCrez5I0Q3RZyo9PeV4jDeB1L71AHnSU/H"
},
"Swarm": {
"ConnMgr": {
"Type": "none",
"GracePeriod": "60s",
"HighWater": 400,
"LowWater": 100
},
"DisableNatPortMap": false,
"RelayClient": {
"Enabled": true,
"StaticRelays": []
},
"RelayService": {
"Enabled": false
},
"EnableHolePunching": true,
"EnableAutoNATService": true,
"DialTimeout": ""
},
"Pubsub": {
"Enabled": true,
"Router": "gossipsub",
"FloodPublish": true
},
"Routing": {
"Type": "dhtclient",
"ProtocolPrefix": "/dbc"
},
"App": {
"LogLevel": "info",
"LogFile": "./test.log",
"LogOutput": "stderr+file",
"PreSharedKey": "f504f536a912a8cf7d00adacee8ed20270c5040d961d7f3da4fccbcbec0ec48a",
"TopicName": "DeepBrainChain",
"Datastore": "./datastore",
"AutoUpgrade": {
"Enabled": true,
"TimeInterval": "1h"
},
"PeersCollect": {
"Enabled": false,
"HeartbeatInterval": "180s",
"ClientProject": ""
}
},
"AIProjects": [
{
"Project": "SuperImage",
"Models": [
{
"Model": "SuperImageAI",
"API": "http://127.0.0.1:1088/models",
"Type": 1
}
]
}
]
}{
"Bootstrap": [
"/ip4/122.99.183.54/tcp/6001/p2p/16Uiu2HAmRTpigc7jAbsLndB2xDEBMAXLb887SBEFhfdJeEJNtqRM",
"/ip4/8.219.75.114/tcp/6001/p2p/16Uiu2HAmS4CErxrmPryJbbEX2HFQbLK8r8xCA5rmzdSU59rHc9AF"
],
"Addresses": [
"/ip4/0.0.0.0/tcp/6001",
"/ip6/::/tcp/6001"
],
"API": {
"Addr": "0.0.0.0:6000"
},
"Identity": {
"PeerID": "16Uiu2HAmJnGqxBqtWGkymSsy5WDKJY5A5NctcUduENADDptQFF4Y",
"PrivKey": "CAISINAckM6QODvCrez5I0Q3RZyo9PeV4jDeB1L71AHnSU/H"
},
"Swarm": {
"ConnMgr": {
"Type": "basic",
"GracePeriod": "60s",
"HighWater": 400,
"LowWater": 100
},
"DisableNatPortMap": true,
"RelayClient": {
"Enabled": false,
"StaticRelays": []
},
"RelayService": {
"Enabled": true
},
"EnableHolePunching": false,
"EnableAutoNATService": true,
"DialTimeout": ""
},
"Pubsub": {
"Enabled": true,
"Router": "floodsub",
"FloodPublish": true
},
"Routing": {
"Type": "dhtserver",
"ProtocolPrefix": "/dbc"
},
"App": {
"LogLevel": "info",
"LogFile": "./test.log",
"LogOutput": "stderr+file",
"PreSharedKey": "f504f536a912a8cf7d00adacee8ed20270c5040d961d7f3da4fccbcbec0ec48a",
"TopicName": "DeepBrainChain",
"Datastore": "./datastore",
"AutoUpgrade": {
"Enabled": true,
"TimeInterval": "1h"
},
"PeersCollect": {
"Enabled": true,
"HeartbeatInterval": "180s",
"ClientProject": ""
}
},
"AIProjects": []
}