Cleaned up config layout.

This commit is contained in:
Gary Talent 2016-02-28 01:03:16 -06:00
parent 6e89b6b13d
commit 0622cac05b
4 changed files with 8 additions and 24 deletions

View File

@ -1,13 +1,8 @@
{
"ApiToken": "<your token here>",
"Services": {
"Minecraft": {
"Port": 25565,
"LogicalDroplet": "minecraft"
}
},
"LogicalServers": {
"Servers": {
"minecraft": {
"Ports": [25565],
"Size": "4gb",
"Region": "nyc3"
}

View File

@ -57,7 +57,7 @@ func (me *DropletHandler) Spinup(name string) (string, error) {
if err != nil {
return "", err
}
vd := me.settings.LogicalServers[name]
vd := me.settings.Servers[name]
createRequest := &godo.DropletCreateRequest{
Name: DROPLET_NS + name,
Region: vd.Region,

View File

@ -28,18 +28,12 @@ func NewServerManager(name string, server ServerHandler, settings Settings) *Ser
sm := new(ServerManager)
sm.name = name
sm.ports = settings.Servers[name].Ports
sm.in = make(chan int)
sm.done = make(chan interface{})
sm.usageScore = 5
sm.server = server
// find the ports associated with this server in settings
for _, s := range settings.Services {
if s.LogicalServer == name {
sm.ports = append(sm.ports, s.Port)
}
}
return sm
}

View File

@ -14,16 +14,11 @@ import (
type Settings struct {
ApiToken string
Services map[string]Service
LogicalServers map[string]LogicalServer
Servers map[string]Server
}
type Service struct {
Port int
LogicalServer string
}
type LogicalServer struct {
type Server struct {
Ports []int
Size string
Region string
}