mirror of
https://github.com/fhmq/hmq.git
synced 2026-04-24 10:38:34 +00:00
* modify * remove * modify * modify * remove no use * add online/offline notification * modify * format log * add reference
45 lines
946 B
Go
45 lines
946 B
Go
/* Copyright (c) 2018, joy.zhou <chowyu08@gmail.com>
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
copyright notice and this permission notice appear in all copies.
|
|
*/
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"os/signal"
|
|
"runtime"
|
|
|
|
"github.com/fhmq/hmq/broker"
|
|
)
|
|
|
|
func main() {
|
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
|
config, err := broker.ConfigureConfig(os.Args[1:])
|
|
if err != nil {
|
|
fmt.Println("configure broker config error: ", err)
|
|
return
|
|
}
|
|
|
|
b, err := broker.NewBroker(config)
|
|
if err != nil {
|
|
fmt.Println("New Broker error: ", err)
|
|
return
|
|
}
|
|
b.Start()
|
|
|
|
s := waitForSignal()
|
|
fmt.Println("signal received, broker closed.", s)
|
|
}
|
|
|
|
func waitForSignal() os.Signal {
|
|
signalChan := make(chan os.Signal, 1)
|
|
defer close(signalChan)
|
|
signal.Notify(signalChan, os.Kill, os.Interrupt)
|
|
s := <-signalChan
|
|
signal.Stop(signalChan)
|
|
return s
|
|
}
|