Start of the run command and the bridge type

This commit is contained in:
Gary Kramlich
2021-11-20 04:59:52 -06:00
parent 8086ad1708
commit 4be28617e0
3 changed files with 90 additions and 0 deletions

35
run/cmd.go Normal file
View File

@@ -0,0 +1,35 @@
package run
import (
"os"
"os/signal"
"syscall"
"gitlab.com/beeper/discord/bridge"
"gitlab.com/beeper/discord/config"
"gitlab.com/beeper/discord/globals"
)
type Cmd struct{}
func (c *Cmd) Run(g *globals.Globals) error {
cfg, err := config.FromFile(g.Config)
if err != nil {
return err
}
bridge, err := bridge.New(cfg)
if err != nil {
return err
}
bridge.Start()
ch := make(chan os.Signal)
signal.Notify(ch, os.Interrupt, syscall.SIGTERM)
<-ch
bridge.Stop()
return nil
}