.
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 {
|
if server {
|
||||||
go zsub.StartHttp()
|
go zsub.StartWatch()
|
||||||
zsub.ServerStart(addr) // 服务进程启动
|
zsub.StartServer(addr) // 服务进程启动
|
||||||
} else {
|
} else {
|
||||||
cmd.ClientRun(addr)
|
cmd.ClientRun(addr)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package zsub
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@@ -12,7 +13,7 @@ func init() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func StartHttp() {
|
func StartWatch() {
|
||||||
dir, _ := os.Getwd()
|
dir, _ := os.Getwd()
|
||||||
webDir := path.Join(dir, "/public")
|
webDir := path.Join(dir, "/public")
|
||||||
|
|
||||||
@@ -22,7 +23,9 @@ func StartHttp() {
|
|||||||
http.HandleFunc("/retimer", retimer)
|
http.HandleFunc("/retimer", retimer)
|
||||||
http.HandleFunc("/topic/publish", publish)
|
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) {
|
func publish(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|||||||
@@ -244,13 +244,13 @@ func (c *ZConn) removeTo(arr []*ZConn) []*ZConn {
|
|||||||
return arr
|
return arr
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServerStart ================== ZHub server =====================================
|
// StartServer ================== ZHub server =====================================
|
||||||
/*
|
/*
|
||||||
ServerStart
|
StartServer
|
||||||
1、load history data
|
1、load history data
|
||||||
2、init server
|
2、init server
|
||||||
*/
|
*/
|
||||||
func ServerStart(addr string) {
|
func StartServer(addr string) {
|
||||||
GetStr("data.dir", "data")
|
GetStr("data.dir", "data")
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
@@ -273,7 +273,7 @@ func ServerStart(addr string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
log.Printf("zhub started listen on: %s \n", addr)
|
log.Println("zhub.server = ", addr)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
conn, err := listen.Accept()
|
conn, err := listen.Accept()
|
||||||
|
|||||||
Reference in New Issue
Block a user