some modify
This commit is contained in:
1 parent
2b56664d85
commit
90beada459
4 files changed
+17
-20
No files matched your search
@@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
_ "net/http/pprof"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
@@ -153,6 +154,16 @@ func (b *Broker) Start() {
|
|||||||
//system monitor
|
//system monitor
|
||||||
go StateMonitor()
|
go StateMonitor()
|
||||||
|
|
||||||
|
if b.config.Debug {
|
||||||
|
startPProf()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func startPProf() {
|
||||||
|
go func() {
|
||||||
|
http.ListenAndServe(":10060", nil)
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func StateMonitor() {
|
func StateMonitor() {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
/* Copyright (c) 2018, joy.zhou <chowyu08@gmail.com>
|
||||||
|
*/
|
||||||
package broker
|
package broker
|
||||||
|
|
||||||
import "github.com/eclipse/paho.mqtt.golang/packets"
|
import "github.com/eclipse/paho.mqtt.golang/packets"
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright (c) 2014 The SurgeMQ Authors. All rights reserved.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package sessions
|
package sessions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ copyright notice and this permission notice appear in all copies.
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"runtime"
|
"runtime"
|
||||||
@@ -19,19 +19,17 @@ func main() {
|
|||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
config, err := broker.ConfigureConfig(os.Args[1:])
|
config, err := broker.ConfigureConfig(os.Args[1:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("configure broker config error: ", err)
|
log.Fatal("configure broker config error: ", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := broker.NewBroker(config)
|
b, err := broker.NewBroker(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("New Broker error: ", err)
|
log.Fatal("New Broker error: ", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
b.Start()
|
b.Start()
|
||||||
|
|
||||||
s := waitForSignal()
|
s := waitForSignal()
|
||||||
fmt.Println("signal received, broker closed.", s)
|
log.Println("signal received, broker closed.", s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func waitForSignal() os.Signal {
|
func waitForSignal() os.Signal {
|
||||||
|
|||||||
Reference in new issue
Block a user