Start of the run command and the bridge type
This commit is contained in:
35
run/cmd.go
Normal file
35
run/cmd.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user