.
git-svn-id: svn://47.119.165.148/zhub@161 e63fbceb-bcc3-4977-ac22-735b83d8d0f4
This commit is contained in:
4
main.go
4
main.go
@@ -45,8 +45,8 @@ func main() {
|
||||
}
|
||||
|
||||
if server {
|
||||
go zsub.StartHttp()
|
||||
zsub.ServerStart(addr) // 服务进程启动
|
||||
go zsub.StartWatch()
|
||||
zsub.StartServer(addr) // 服务进程启动
|
||||
} else {
|
||||
cmd.ClientRun(addr)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package zsub
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
@@ -12,7 +13,7 @@ func init() {
|
||||
|
||||
}
|
||||
|
||||
func StartHttp() {
|
||||
func StartWatch() {
|
||||
dir, _ := os.Getwd()
|
||||
webDir := path.Join(dir, "/public")
|
||||
|
||||
@@ -22,7 +23,9 @@ func StartHttp() {
|
||||
http.HandleFunc("/retimer", retimer)
|
||||
http.HandleFunc("/topic/publish", publish)
|
||||
|
||||
http.ListenAndServe(":1217", nil)
|
||||
watchAddr := GetStr("service.zhub.watch", "0.0.0.0:1217")
|
||||
log.Println("zhub.watch = ", watchAddr)
|
||||
http.ListenAndServe(watchAddr, nil)
|
||||
}
|
||||
|
||||
func publish(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@@ -244,13 +244,13 @@ func (c *ZConn) removeTo(arr []*ZConn) []*ZConn {
|
||||
return arr
|
||||
}
|
||||
|
||||
// ServerStart ================== ZHub server =====================================
|
||||
// StartServer ================== ZHub server =====================================
|
||||
/*
|
||||
ServerStart
|
||||
StartServer
|
||||
1、load history data
|
||||
2、init server
|
||||
*/
|
||||
func ServerStart(addr string) {
|
||||
func StartServer(addr string) {
|
||||
GetStr("data.dir", "data")
|
||||
|
||||
go func() {
|
||||
@@ -273,7 +273,7 @@ func ServerStart(addr string) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("zhub started listen on: %s \n", addr)
|
||||
log.Println("zhub.server = ", addr)
|
||||
|
||||
for {
|
||||
conn, err := listen.Accept()
|
||||
|
||||
Reference in New Issue
Block a user