Cleaned up config layout.
This commit is contained in:
parent
6e89b6b13d
commit
0622cac05b
@ -1,13 +1,8 @@
|
||||
{
|
||||
"ApiToken": "<your token here>",
|
||||
"Services": {
|
||||
"Minecraft": {
|
||||
"Port": 25565,
|
||||
"LogicalDroplet": "minecraft"
|
||||
}
|
||||
},
|
||||
"LogicalServers": {
|
||||
"Servers": {
|
||||
"minecraft": {
|
||||
"Ports": [25565],
|
||||
"Size": "4gb",
|
||||
"Region": "nyc3"
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
11
settings.go
11
settings.go
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user