Compare commits
No commits in common. "8493c7cb4052b556129276236a95d16a2b5b0e12" and "58495d59c16b8781eb4652857110b3c75e4a7683" have entirely different histories.
8493c7cb40
...
58495d59c1
@ -52,9 +52,9 @@ Support for NATS is only less than 150 lines.
|
||||
The quickest way how to run lobby on your server is this:
|
||||
|
||||
```shell
|
||||
wget -O /usr/local/bin/lobbyd https://github.com/by-cx/lobby/releases/download/v1.1/lobbyd-1.1-linux-amd64
|
||||
wget -O /usr/local/bin/lobbyd https://github.com/by-cx/lobby/releases/download/v1.0/lobbyd-1.0-linux-amd64
|
||||
chmod +x /usr/local/bin/lobbyd
|
||||
wget -O /usr/local/bin/lobbyctl https://github.com/by-cx/lobby/releases/download/v1.1/lobbyctl-1.1-linux-amd64
|
||||
wget -O /usr/local/bin/lobbyctl https://github.com/by-cx/lobby/releases/download/v1.0/lobbyctl-1.0-linux-amd64
|
||||
chmod +x /usr/local/bin/lobbyctl
|
||||
|
||||
# Update NATS_URL and LABELS here
|
||||
|
@ -63,9 +63,6 @@ func addLabelsHandler(c echo.Context) error {
|
||||
return c.String(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
|
||||
// Update the other nodes with this new change
|
||||
sendDiscoveryPacket()
|
||||
|
||||
return c.String(http.StatusOK, "OK")
|
||||
}
|
||||
|
||||
@ -87,8 +84,5 @@ func deleteLabelsHandler(c echo.Context) error {
|
||||
return c.String(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
|
||||
// Update the other nodes with this new change
|
||||
sendDiscoveryPacket()
|
||||
|
||||
return c.String(http.StatusOK, "OK")
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ var localHost server.LocalHost
|
||||
var config Config
|
||||
|
||||
var shuttingDown bool
|
||||
var sendDiscoveryPacketTrigger chan bool = make(chan bool)
|
||||
|
||||
func init() {
|
||||
// Load config from environment variables
|
||||
@ -89,30 +88,19 @@ func sendGoodbyePacket() {
|
||||
}
|
||||
}
|
||||
|
||||
// sendDiscoveryPacket sends a single discovery packet out
|
||||
// sendDisoveryPacket sends discovery packet regularly so the network know we exist
|
||||
func sendDiscoveryPacket() {
|
||||
sendDiscoveryPacketTrigger <- true
|
||||
}
|
||||
|
||||
// sendDisoveryPacket sends discovery packet to the driver which passes it to the
|
||||
// other nodes. By this it propagates any change that happens in the local discovery struct.
|
||||
// Every tune trigger is triggered it sends one message.
|
||||
func sendDiscoveryPacketTask(trigger chan bool) {
|
||||
for {
|
||||
// We are waiting for the trigger
|
||||
<-trigger
|
||||
|
||||
if !shuttingDown {
|
||||
discovery, err := localHost.GetIdentification()
|
||||
if err != nil {
|
||||
log.Println("sending discovery identification error: %v", err)
|
||||
log.Printf("sending discovery identification error: %v\n", err)
|
||||
}
|
||||
|
||||
err = driver.SendDiscoveryPacket(discovery)
|
||||
if err != nil {
|
||||
log.Println(err.Error())
|
||||
}
|
||||
log.Println(err)
|
||||
}
|
||||
time.Sleep(time.Duration(config.KeepAlive) * time.Second)
|
||||
|
||||
if shuttingDown {
|
||||
break
|
||||
@ -157,21 +145,7 @@ func main() {
|
||||
|
||||
// If config.Register is false this instance won't be registered with other nodes
|
||||
if config.Register {
|
||||
// This is background process that sends the message
|
||||
go sendDiscoveryPacketTask(sendDiscoveryPacketTrigger)
|
||||
|
||||
// This triggers the process
|
||||
go func() {
|
||||
for {
|
||||
sendDiscoveryPacket()
|
||||
|
||||
time.Sleep(time.Duration(config.KeepAlive) * time.Second)
|
||||
|
||||
if shuttingDown {
|
||||
break
|
||||
}
|
||||
}
|
||||
}()
|
||||
go sendDiscoveryPacket()
|
||||
} else {
|
||||
log.Println("standalone mode, I won't register myself")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user