mirror of
https://github.com/dragonheim/gagent.git
synced 2025-04-12 00:22:40 -07:00
Extending the setup mode.
This commit is contained in:
parent
5e69931ed7
commit
7a2ca771f2
3 changed files with 43 additions and 11 deletions
11
assets/examples/genesis.hcl
Normal file
11
assets/examples/genesis.hcl
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
"genesis_time" = "2021-10-25:00:00.000000000Z"
|
||||||
|
"chain_id" = "gagent_ledger"
|
||||||
|
|
||||||
|
"agent" = {
|
||||||
|
"client" = "7e9d13fe-5151-5876-66c0-20ca03e8fca4"
|
||||||
|
"shasum" = "a76f7c3c7bc0f94b4f8aa63c605f8534db5675bb05d761f4461127fcadbf32d4"
|
||||||
|
"status" = "complete"
|
||||||
|
}
|
||||||
|
"clients" = {
|
||||||
|
"client" = "7e9d13fe-5151-5876-66c0-20ca03e8fca4"
|
||||||
|
}
|
12
assets/examples/genesis.json
Normal file
12
assets/examples/genesis.json
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"genesis_time": "2021-10-25:00:00.000000000Z",
|
||||||
|
"chain_id": "gagent_ledger",
|
||||||
|
"agent": {
|
||||||
|
"client": "7e9d13fe-5151-5876-66c0-20ca03e8fca4",
|
||||||
|
"shasum": "a76f7c3c7bc0f94b4f8aa63c605f8534db5675bb05d761f4461127fcadbf32d4",
|
||||||
|
"status": "complete"
|
||||||
|
},
|
||||||
|
"clients": {
|
||||||
|
"client": "7e9d13fe-5151-5876-66c0-20ca03e8fca4"
|
||||||
|
}
|
||||||
|
}
|
|
@ -43,17 +43,7 @@ var (
|
||||||
|
|
||||||
var exitCodes = struct {
|
var exitCodes = struct {
|
||||||
m map[string]int
|
m map[string]int
|
||||||
}{m: map[string]int{
|
}{m: map[string]int{}}
|
||||||
"SUCCESS": 0,
|
|
||||||
"CONFIG_FILE_MISSING": 1,
|
|
||||||
"SETUP_FAILED": 2,
|
|
||||||
"INVALID_MODE": 3,
|
|
||||||
"AGENT_LOAD_FAILED": 4,
|
|
||||||
"AGENT_MISSING_TAGS": 5,
|
|
||||||
"NO_ROUTERS_DEFINED": 6,
|
|
||||||
"NO_WORKERS_DEFINED": 7,
|
|
||||||
"AGENT_NOT_DEFINED": 8,
|
|
||||||
}}
|
|
||||||
|
|
||||||
var config gs.GagentConfig
|
var config gs.GagentConfig
|
||||||
var agent gs.AgentDetails
|
var agent gs.AgentDetails
|
||||||
|
@ -121,6 +111,15 @@ func main() {
|
||||||
rootBody.SetAttributeValue("name", cty.StringVal(config.Name))
|
rootBody.SetAttributeValue("name", cty.StringVal(config.Name))
|
||||||
rootBody.SetAttributeValue("mode", cty.StringVal(config.Mode))
|
rootBody.SetAttributeValue("mode", cty.StringVal(config.Mode))
|
||||||
rootBody.SetAttributeValue("uuid", cty.StringVal(config.UUID))
|
rootBody.SetAttributeValue("uuid", cty.StringVal(config.UUID))
|
||||||
|
rootBody.SetAttributeValue("listenaddr", cty.StringVal("0.0.0.0"))
|
||||||
|
rootBody.SetAttributeValue("clientport", cty.NumberIntVal(config.ClientPort))
|
||||||
|
rootBody.SetAttributeValue("routerport", cty.NumberIntVal(config.RouterPort))
|
||||||
|
rootBody.SetAttributeValue("workerport", cty.NumberIntVal(config.WorkerPort))
|
||||||
|
rootBody.AppendNewline()
|
||||||
|
|
||||||
|
clientBlock1 := rootBody.AppendNewBlock("client", []string{config.Name})
|
||||||
|
clientBody1 := clientBlock1.Body()
|
||||||
|
clientBody1.SetAttributeValue("clientid", cty.StringVal(config.UUID))
|
||||||
rootBody.AppendNewline()
|
rootBody.AppendNewline()
|
||||||
|
|
||||||
routerBlock1 := rootBody.AppendNewBlock("router", []string{config.Name})
|
routerBlock1 := rootBody.AppendNewBlock("router", []string{config.Name})
|
||||||
|
@ -128,6 +127,13 @@ func main() {
|
||||||
routerBody1.SetAttributeValue("routerid", cty.StringVal(config.UUID))
|
routerBody1.SetAttributeValue("routerid", cty.StringVal(config.UUID))
|
||||||
routerBody1.SetAttributeValue("address", cty.StringVal("127.0.0.1"))
|
routerBody1.SetAttributeValue("address", cty.StringVal("127.0.0.1"))
|
||||||
routerBody1.SetAttributeValue("clientport", cty.NumberIntVal(config.ClientPort))
|
routerBody1.SetAttributeValue("clientport", cty.NumberIntVal(config.ClientPort))
|
||||||
|
routerBody1.SetAttributeValue("routerport", cty.NumberIntVal(config.RouterPort))
|
||||||
|
routerBody1.SetAttributeValue("workerport", cty.NumberIntVal(config.WorkerPort))
|
||||||
|
rootBody.AppendNewline()
|
||||||
|
|
||||||
|
workerBlock1 := rootBody.AppendNewBlock("worker", []string{config.Name})
|
||||||
|
workerBody1 := workerBlock1.Body()
|
||||||
|
workerBody1.SetAttributeValue("workerid", cty.StringVal(config.UUID))
|
||||||
rootBody.AppendNewline()
|
rootBody.AppendNewline()
|
||||||
|
|
||||||
log.Printf("\n%s", f.Bytes())
|
log.Printf("\n%s", f.Bytes())
|
||||||
|
@ -164,6 +170,8 @@ func init() {
|
||||||
exitCodes.m["NO_WORKERS_DEFINED"] = 4
|
exitCodes.m["NO_WORKERS_DEFINED"] = 4
|
||||||
exitCodes.m["AGENT_NOT_DEFINED"] = 5
|
exitCodes.m["AGENT_NOT_DEFINED"] = 5
|
||||||
exitCodes.m["AGENT_LOAD_FAILED"] = 6
|
exitCodes.m["AGENT_LOAD_FAILED"] = 6
|
||||||
|
exitCodes.m["AGENT_MISSING_TAGS"] = 7
|
||||||
|
exitCodes.m["AGENT_NOT_DEFINED"] = 8
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the configuration
|
* Initialize the configuration
|
||||||
|
@ -293,6 +301,7 @@ func init() {
|
||||||
if opts["router"] == true {
|
if opts["router"] == true {
|
||||||
config.Mode = "router"
|
config.Mode = "router"
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts["worker"] == true {
|
if opts["worker"] == true {
|
||||||
config.Mode = "worker"
|
config.Mode = "worker"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue