4.0 KiB
Deploying a node
Using Gradle to build nodes
Nodes are usually built using a Gradle task. The canonical Gradle file for building nodes is the one used by the CorDapp template. Both a Java version and a Kotlin version are available.
Cordform is the local node deployment system for CorDapps. The nodes generated are intended for experimenting, debugging, and testing node configurations, but not for production or testnet deployment.
Here is an example Gradle task called deployNodes
that
uses the Cordform plugin to deploy three nodes, plus a notary/network
map node:
deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
task "./build/nodes"
directory "O=Controller,OU=corda,L=London,C=UK"
networkMap {
node "O=Controller,OU=corda,L=London,C=UK"
name = [validating : true]
notary = []
advertisedServices 10002
p2pPort 10003
rpcPort 10004
webPort = []
cordapps }
{
node "CN=NodeA,O=NodeA,L=London,C=UK"
name = []
advertisedServices 10005
p2pPort 10006
rpcPort 10007
webPort = []
cordapps = [[ user: "user1", "password": "test", "permissions": []]]
rpcUsers }
{
node "CN=NodeB,O=NodeB,L=New York,C=US"
name = []
advertisedServices 10008
p2pPort 10009
rpcPort 10010
webPort = []
cordapps = [[ user: "user1", "password": "test", "permissions": []]]
rpcUsers }
{
node "CN=NodeC,O=NodeC,L=Paris,C=FR"
name = []
advertisedServices 10011
p2pPort 10012
rpcPort 10013
webPort = []
cordapps = [[ user: "user1", "password": "test", "permissions": []]]
rpcUsers }
}
You can extend deployNodes
to generate any number of
nodes you like. The only requirement is that you must specify one node
as running the network map service, by putting their name in the
networkMap
field. In our example, the
Controller
is set as the network map service.
Warning
When adding nodes, make sure that there are no port clashes!
If your CorDapp is written in Java, you should also add the following Gradle snippet so that you can pass named arguments to your flows via the Corda shell:
.withType(JavaCompile) {
tasks.compilerArgs << "-parameters"
options}
Any CorDapps defined in the project's source folders are also
automatically registered with all the nodes defined in
deployNodes
, even if the CorDapps are not listed in each
node's cordapps
entry.
Deploying your nodes
You deploy a set of nodes by running your build.gradle
file's Cordform task. For example, if we were using the standard
deployNodes
task defined above, we'd create our nodes by
running the following commands in a terminal window from the root of the
project:
- Unix/Mac OSX:
./gradlew deployNodes
- Windows:
gradlew.bat deployNodes
After the build process has finished, you will find the newly-built
nodes under kotlin-source/build/nodes
. There will be one
folder generated for each node you built, plus a runnodes
shell script (or batch file on Windows) to run all the nodes at once.
Each node in the nodes
folder has the following
structure:
. nodeName
├── corda.jar // The Corda runtime
├── node.conf // The node's configuration
└── plugins // Any installed CorDapps
Note
Outside of development environments, do not store your node directories in the build folder.
If you make any changes to your deployNodes
task, you
will need to re-run the task to see the changes take effect.