package main import ( "log" "os" "os/signal" "forge.cadoles.com/wpetit/rebound" "forge.cadoles.com/wpetit/rebound/http" "forge.cadoles.com/wpetit/rebound/ssh" "github.com/pkg/errors" ) var Version string = "unknown" func main() { opts := rebound.DefaultOptions() if err := opts.ParseEnv(); err != nil { log.Fatalf("[ERROR] %+v", errors.WithStack(err)) } opts.HTTP.TemplateData.Version = Version server := rebound.NewServer( rebound.WithAddress(opts.Address), rebound.WithStatsFile(opts.StatsFile), rebound.WithStatsFileSaveInterval(opts.StatsFileSaveInterval), rebound.WithSSHOption( ssh.WithSockDir(opts.SSH.SockDir), ssh.WithPublicHost(opts.SSH.PublicHost), ssh.WithPublicPort(opts.SSH.PublicPort), ssh.WithHostKey(opts.SSH.HostKey), ), rebound.WitHTTPOption( http.WithCustomDir(opts.HTTP.CustomDir), http.WithTemplateData(opts.HTTP.TemplateData), ), ) if err := server.Start(); err != nil { log.Fatalf("[FATAL] %+v", errors.WithStack(err)) } c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt) <-c if err := server.Stop(); err != nil { log.Fatalf("[FATAL] %+v", errors.WithStack(err)) } }