Genvid configuration files¶
The Genvid configuration can be contained in multiple files respecting a specific schema. The file can be writen in JSON or HCL format.
For example, the Tutorial project contains 4 configuration files.
sample.hcl¶
version = "1.7.0"
settings {
encode {
input {
width = 1280
height = 720
}
output {
width = 1280
height = 720
}
}
info {
description = "Sample to demonstrate genvid"
game = "Tutorial"
name = "Tutorial Sample"
}
}
config
{
local
{
appdir = "{{env `PROJECTDIR` | js}}\\app"
}
}
This file contains the basic information about the sample.
- The stream encoding.
- The basic stream info.
- The secrets. (You’ll need to change them.)
- A local configuration. This local configuration goes into the Consul key-value store for use in the Nomad template.
stream.hcl¶
version = "1.7.0"
secrets {
disco {
GENVID_DISCO_SECRET = "secrettochange"
}
command {
GENVID_COMMAND_SECRET = "anothersecret"
}
}
This file contains the secrets (you need to change the secret values).
events.json¶
{
"version": "1.7.0",
"event": {
"game": {
"maps": [
{
"id": "changeColor",
"source": "userinput",
"where": {"key": ["changeColor", "<name>"], "name": "<color>", "type": "string"},
"key": ["changeColor", "<name>", "<color>"], "value": 1
},
{
"id": "reset",
"source": "userinput",
"where": {"key": ["reset"], "name": "<name>", "type": "string"},
"key": ["reset", "<name>"], "value": 1
},
{
"id": "cheer",
"source": "userinput",
"where": {"key": ["cheer"], "name": "<name>", "type": "string"},
"key": ["cheer", "<name>"], "value": 1
}
],
"reductions": [
{
"id": "changeColor",
"where": {"key": ["changeColor", "<name>", "<color>"]},
"key": ["<name>", "<color>"],
"value": ["$count"],
"period": 250
},
{
"id": "reset",
"where": {"key": ["reset", "<name>"]},
"key": ["<name>"],
"value": ["$count"],
"period": 250
},
{
"id": "cheer",
"where": {"key": ["cheer", "<name>"]},
"key": ["<name>"],
"value": ["$sum"],
"period": 250
}
]
}
}
}
The sample events.json
file contains the events description. We group
events together under a unique identifier allowing you to enable and disable
them as a group. In the sample, the identifier is game
.
See Scalable Event Channels for more information on the format.
game.hcl¶
version = "1.7.0"
job "tutorial" {
}
log "game" {
job = "tutorial"
fileName = "stderr"
logLevel = true
}
config {
local {
binary {
tutorial {
path = "{{env `PROJECTDIR` | js}}\\app\\x64\\Release\\Tutorial.exe"
}
}
}
}
This sample game.hcl
file contains the game configuration information in 3 categories.
The first element is a new job. The name of the job should match the name of the template file as well as the name of the job in the template file. Job configurations have two attributes:
- dependencies: A list of services to wait on before starting the
job. The default is
none
. - autostart: If the job must be automatically started on a start command without arguments.
The second is the log
element. It gives the options to pass to
POST /log/logs
when you run genvid-sdk log game
.
The last is the config
element. The content is added to the key-value store,
where each object describes a folder and each value is converted to a string and
inserted as a key.
The consul-template’s plugin calls the DOS command where with the argument node and returns the command output. You can use your own executables as long as they are in your path when the project is loaded. The js method ensures elements like Windows path separators are correctly quoted in the file.
web.hcl¶
version = "1.7.0"
job "web" {}
log "web" {
job = "web"
task = "web"
fileName = "stdout"
}
log "weberr" {
job = "web"
task = "web"
fileName = "stderr"
}
link "web" {
name = "Tutorial Demo"
template = "http://${service `web`}/"
}
link "admin" {
name = "Tutorial Admin"
template = "http://${serviceEx `web` `` true}/admin"
}
config {
local {
website {
root = "{{env `PROJECTDIR` | js}}\\web"
script = "{{env `PROJECTDIR` | js}}\\web\\bin\\www"
}
binary {
node {
path = "{{plugin `where.exe` `node` | js}}"
}
}
}
}
The web.hcl
section is similar to the game.hcl
section, but for
the web server. It contains a single job
with only the default attribute and
two log
elements: one for the standard output and the other for the
standard error.
It contains multiple link elements used as uris in the system. By running
genvid-sdk open
you can see the list of available links.
These links use a template system to produce the final link. In the Tutorial
sample, we transform the template http://${service \`web\`}/
into the
website uri.
The available template functions are:
- service service: The service address and port.
- serviceEx service tag external: The service address and port. The tag is an arbitrary value used to find a service. The external attribute is asking for an external address.
- key key: The value from a Consul key-value pair.
- keyOrDefault key default_value: The value from a Consul key-value pair. Gets the default value if the key is not available.
The web section also contains config for the cloud environment.