Sybren A. Stüvel d153db4280 Work in progress on using UPnP/SSDP to make the Worker find its Manager
Due to the way SSDP works, Flamenco Manager needs to know its own URL,
where the Workers can reach it. These URLs are now found, and since there
can be multiple (like IPv6 + IPv4) they are all sent in a SSDP
notification as ;-separated strings.
2022-03-04 17:44:04 +01:00

47 lines
959 B
Go

package main
import (
"os"
"os/signal"
"syscall"
"time"
"git.blender.org/flamenco/internal/upnp_ssdp"
"github.com/mattn/go-colorable"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"golang.org/x/net/context"
)
func main() {
output := zerolog.ConsoleWriter{Out: colorable.NewColorableStdout(), TimeFormat: time.RFC3339}
log.Logger = log.Output(output)
c, err := upnp_ssdp.NewClient(log.Logger)
if err != nil {
panic(err)
}
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
// Handle Ctrl+C
signals := make(chan os.Signal, 1)
signal.Notify(signals, os.Interrupt)
signal.Notify(signals, syscall.SIGTERM)
go func() {
for signum := range signals {
log.Info().Str("signal", signum.String()).Msg("signal received, shutting down")
cancel()
}
}()
urls, err := c.Run(ctx)
if err != nil {
panic(err)
}
for _, url := range urls {
log.Info().Str("url", url).Msg("found URL")
}
}