Grid Configuration

The grid configuration file contains configuration specific to the distributed system and to the local server instance. The configuration system supports both a tokenization system and a plugin system that enables configuration tokens to be pulled from:

  • Environment variables

  • The constants config section

  • Cloud hosting agents (Amazon, Azure)

  • Any other source developers create plugins for

Example configuration file:

{

"constants": {
    "publicIp": "{host-ip}",
    "elasticHost": "127.0.0.1",
    "zookeeperHost": "{host-ip}",
    "loadBalancedIp": "{host-ip}",
    "rootDirectory": "{workingDirectory}/../../../..",
    "dataDirectory": "{rootDirectory}/data/{configName}",
    "sharedDirectory": "{rootDirectory}/data/shared",
    "cluster": "test",
    "n2nPort": "40243",
    "apiHttpPort": "80",
    "apiHttpsPort": "443",
    "adminApiHttpPort": "81",

    "udpPort": "30101",
    "tempDir": "{rootDirectory}/tmp/{configName}"
},
"configs": [
    // Paths to protected files accessible only by the stormancer process.
    //The content of these files is added to constants at runtime.
    //"{dataDirectory}/secrets/passwords.json"
],
"security": {
    "privateKeyStores": [
    {
        "path": "{dataDirectory}/secrets"
    }
    ]
},
//Elasticsearch DB connection config
"elasticsearch": {
    "credentials": {
    "basic": {
        "login": "elastic",
        "password": "kEdTrgEdLR30YZDLk3KknYn8"
    }
    },
    //Elasticsearch endpoint. Defaults to "http://localhost:9200"
    "endpoint": "http://{elasticHost}:9200/",
    "index": "infra-debug-{cluster}",
    "disableSniffing": true,
    "singleTypePerIndex": true

},
"stats": {
    "storage": [ "http://localhost:9200" ],
    "index-template": "stats_{{0}}_{{1}}_{{2}}"
},
"git": {
    //Directory containing git
    "path": "../../../Standalone/git",
    //Directory used to store the application repositories
    "repositoriesDirectory": "{sharedDirectory}/repositories",
    //Git home directory
    "homeDirectory": "~/gitHome"

},
"api": {
    //Config for the public API
    "public": {
    //Endpoint used for web server binding
    "bindings": [
        {
        "endpoint": "*:{apiHttpPort}"
        }
        //},

        //{
        //  "endpoint": [ "*:{apiHttpsPort}" ],
        //  "settings": {
        //    "https": "lettuceEncrypt"
        //  }
        //}
    ],
    //Published endpoint (used by clients to connect to the server)
    "published": [
        "http://{loadBalancedIp}:{apiHttpPort}"
        //"https://{loadBalancedIp}:{apiHttpsPort}"
    ]
    },
    //Config for the admin API.
    "admin": {
    //Endpoint used for web server binding
    "bindings": [
        {
        "endpoint": "127.0.0.1:{adminApiHttpPort}"
        }
    ],
    //Published endpoint (used by clients to connect to the server)
    "published": [
        "http://127.0.0.1:{adminApiHttpPort}"
    ]
    }

    ////Private key used by the web server for HTTPS.
    //"privateKey": {
    //  "path": "https.pem",
    //  "password": "{secrets-cluster-pk-password}"
    //}

},

"identity": {
    //Name of the node. Automatically generated if not specified here.
    //It's recommanded to have different names for each node when running distributed.
    "name": "test"
},
//Contains the list of public endpoints to the node and their configuration.
"endpoints": {
    "udp1": {
    "type": "raknet",
    "port": "{udpPort}",
    "maxConnections": 100,
    "publicEndpoint": "{publicIp}:{udpPort}"
    },
    "ws": {
    "type": "websocket"
    }
},
"hosting": {
    "packages": {
    "applications": "{sharedDirectory}/apps",
    "hostSources": [
        "https://api.nuget.org/v3/index.json"
    ],
    //Sources used during dotnet restore for server applications.
    "sources": [
        "https://api.nuget.org/v3/index.json"
    ]
    },

    "dataStorage": "{dataDirectory}/storage",
    //Root directory where server applications are loaded.
    //The directory of a specific app is : <appInstallDirectory>\<accountId>\<appName>\<deploymentId>
    "applicationInstallDirectory": "{tempDir}/hosting/apps/",
    //Directory where application hosts are loaded.
    "hostsDirectory": "{tempDir}/hosting/hosts/",
    //Local package storage
    "localPackageStorageDirectory": "{tempDir}/packages",

    //Set to true to launch the debugger whenever an host starts. Must be disabled in production.
    "launchDebugger": true,
    //Port range for application HTTP communications
    "allowedPortsRange": "42000-42200",

    "gc": {
    //Interval of time in seconds between two subsequent run of the server application GC.
    "interval": 60,
    //inactivity period in seconds before an application becomes eligible for GC.
    "timeout": 600
    }
},


//Configuration for the geo IP plugin
"geoip": {
    //Path to the geo ip db in the file system.
    "db": "{dataDirectory}/geoip/GeoLite2-City.mmdb"
},
//Configuration of the self hosted management portal
"portal": {
    //Enables or disables the portal
    "enabled": true,
    //Endpoint used to access the portal (if enabled)
    "bindingEndpoint": "http://*:9091"
},
"socketPolicyServer": {
    "enabled": false,
    "port": 843
},


"cluster": {
    //Id of the cluster. Defaults to 'default'
    "name": "test",

    //The private key associated with this cluster. All nodes should use the same key, and the subject should be the clusterId (in the example, test)
    //"privateKey": {
    //  "path": "{dataDirectory}/secrets/test.pem",
    //  "password": "{secrets-cluster-pk-password}"
    //},
    //A set of tags advertised by the cluster
    "tags": [ "main" ],
    //Does the cluster requires node authentication? If no, node 2 node communications are not encrypted, and federation is not possible.
    //Setting to true requires setting the private key.
    "requireNodeAuthentication": false,
    //Mode used to discover new nodes. Currently only support for zookeeper discovery is enabled.
    "coordination": {
    "type": "zookeeper",
    "endpoints": "{zookeeperHost}:2181",
    "sessionTimeout": 4000

    },
    //Is the node candidate for leadership
    "leader": true,

    //communication endpoint for the node.
    "endpoint": "*:{n2nPort}"
    //Zookeeper configuration. Instance must be restarted to take changes into account.

},
"federation": {
    //Endpoint used by nodes of other clusters in the federation to connect to this node
    //leave empty or set to null to prevent this node from accepting connections from nodes in other clusters.
    "publicEndpoint": "{publicIp}:{n2nPort}",
    "clusters": {
    //List of endpoints to try to get metadata about the remote clusters
    "endpoints": [],
    //Paths containing the public keys authenticating each remote cluster (
    "certificateSources": [
        {
        "path": "{dataDirectory}/certs"
        }
    ]
    }
},
//nat traversal configuration (used to establish p2p communication between clients)
"p2p": {
    //The number of p2p ping attempts that may be active at the same time between two peers.
    "maxConcurrentPings": 8,
    //
    "enableRelay": true
},
"logging": {
    "outputs": {
        "nlog": {
            "enabled": true
        }
    },
    "applications": {
        "minLogLevel": "Trace" //Min logging level for applications. Trace, Debug, Info, Warn, Error, Fatal
    }

},
"tokens": {
    "maxUserDataSize": 10240,
    "randomAccount": {
        "randomApp": {
            "useNativeDateFormat": false // disable nativeDate format in tokens for randomAccount/randomApp
        },
        "useNativeDateFormat": true // enable nativeDate format in tokens for app in randomAccount different from randomAccount/randomApp
    },
    "useNativeDateFormat": false //// disable nativeDate format in all other accounts.
},
"sharding": {
    "shardGroups": {
        //The primary shard group is the default shardgroup in the cluster
        "primary": {
            "replicates": 1,
            "shards": 8,
            "persistent": false
        },
        //The storage shard group is a persistent shard group whose shard allocation is kept between restarts, and used by the cluster for replicated persistent storage.
        "storage": {
            "replicates": 1,
            "shards": 8,
            "persistent": true
        }
    }
},
"plugins": {
    "aws": {
        "enabled": false
    }
    ,
    "lettuceEncrypt": {
        "enabled": false,
        // Which API type to use LettuceEncrypt with. Due to a current limitation, it cannot be enabled for both public and admin APIs.
        // Valid values are "public" and "admin".
        "apiType": "public",
        // Email for certificate renewal (required)
        "email": "email@email.com",
        // Domain name(s) to request certificates for
        "domainNames": [ "{loadBalancedIp}" ],
        // Use Let's Encrypt staging server for issuing certificate. true for testing ; false for prod
        "useStagingServer": true,
        // Directory to be used to save LettuceEncrypt data. Required.
        "certificateDirectory": "C:/strm-data/lettuceEncrypt",
        // Show detailed LettuceEncrypt (and Kestrel) logs.
        "showLogs": true
    }
}
}

Server endpoint definition

At least one endpoint for the public API, and another for the admin API, must be defined in your configuration file. They reside under the api section.

In the following example, we define two endpoints:

  • One for the public API, listening on INADDR_ANY (the wildcard value in endpoint) and accepting HTTP connections from localhost only on port 80 (we didn’t specify a port because 80 is the default for HTTP).

  • One for the admin API, also listening on INADDR_ANY, but this time on port 81, also accepting connections from localhost only.

{
    "api": {
        "public": {
            "bindings": [
                {
                    "endpoint": "*",
                    "settings": {
                        "key": "value"
                    }
                }
            ],
            "published": [
                "http://127.0.0.1"
            ]
        },
        "admin": {
            "bindings": [
                {
                    "endpoint": "*:81",
                    "settings": {
                        "key": "value"
                    }
                }
            ],
            "published": [
                "http://127.0.0.1:81"
            ]
        }
    }
}

As you can see, each endpoint can have arbitrary settings associated to it. These settings can be interpreted by Stormancer plugins, such as LettuceEncrypt Support for Stormancer.