示例#1
0
func main() {
	srv := syslogbot.NewBot(os.Args[1])
	s := syslog.NewServer()
	s.AddHandler(srv.SyslogHandler())
	s.Listen("0.0.0.0:514")
	s.Listen("0.0.0.0:1514")
	sc := make(chan os.Signal, 2)
	signal.Notify(sc, syscall.SIGTERM, syscall.SIGINT)
	<-sc
	log.Println("Shutdown the server...")
	s.Shutdown()
	log.Println("Server is down")
}
示例#2
0
// newSyslogServer start a syslog server using a unix socket to listen for connections
func newSyslogServer(path string) (*syslogServer, error) {
	glog.Infof("Starting syslog server for haproxy using %v as socket", path)
	// remove the socket file if exists
	os.Remove(path)

	server := &syslogServer{syslog.NewServer()}
	server.AddHandler(newHandler())
	err := server.Listen(path)
	if err != nil {
		return nil, err
	}

	return server, nil
}
示例#3
0
func main() {
	flag.Parse()
	s := syslog.NewServer()
	s.AddHandler(newHandler())
	s.Listen(flag.Arg(0))

	// Wait for terminating signal
	sc := make(chan os.Signal, 2)
	signal.Notify(sc, syscall.SIGTERM, syscall.SIGINT)
	<-sc

	fmt.Println("Shutdown the server...")
	s.Shutdown()
}
示例#4
0
func main() {
	address := flag.String("addr", ":514", "address")
	flag.Parse()

	server := syslog.NewServer()
	server.AddHandler(newHandler())
	server.Listen(*address)

	sig := make(chan os.Signal, 2)
	signal.Notify(sig, syscall.SIGTERM, syscall.SIGINT)
	<-sig

	server.Shutdown()
	fmt.Println("Server is now down.")
}
示例#5
0
文件: main.go 项目: CodeJuan/deis
func main() {
	// Create a server with one handler and run one listen gorutine
	s := syslog.NewServer()
	s.AddHandler(newHandler())
	s.Listen("0.0.0.0:1514")

	// Wait for terminating signal
	sc := make(chan os.Signal, 2)
	signal.Notify(sc, syscall.SIGTERM, syscall.SIGINT)
	<-sc

	// Shutdown the server
	fmt.Println("Shutdown the server...")
	s.Shutdown()
	fmt.Println("Server is down")
}
示例#6
0
// StartSyslogServer start a syslog server listening in the specified path
func StartSyslogServer(path string) error {
	glog.Info("Starting syslog server for haproxy")
	s := syslog.NewServer()
	s.AddHandler(newHandler())
	return s.Listen(path)
}