Terry-Mao/gopush-cluster
is a go push server cluster (support websocket, tcp protocol).
- lightweight
- high performance
- pure golang implementation
- message expired
- offline message store
- public message or private message push
- multiple subscribers (can restrict max subscribers)
- heartbeat(service heartbeat or tcp keepalive)
- auth (if a subscriber not auth then can not connect to comet node)
- multiple protocol (websocket, tcp, todo http longpolling)
- stat
- cluster support (easy add or remove comet & web & message node)
- failover support (zookeeper)
$ yum -y install java-1.7.0-openjdk
$ yum -y install gcc-c++
1.mkdir
$ mkdir -p /data/apps
$ mkdir -p /data/logs
$ mkdir -p /data/programfiles
2.download zookeeper, suggest version: '3.4.5'.
$ cd /data/programfiles
$ wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.5/zookeeper-3.4.5.tar.gz
$ tar -xvf zookeeper-3.4.5.tar.gz -C ./
3.compile && install
$ cd zookeeper-3.4.5/src/c
$ ./configure
$ make && make install
$ cp /data/programfiles/zookeeper-3.4.5/conf/zoo_sample.cfg /data/programfiles/zookeeper-3.4.5/conf/zoo.cfg
4.start zookeeper
$ cd /data/programfiles/zookeeper-3.4.5/bin
$ nohup ./zkServer.sh start &
$ cd /data/programfiles
$ wget https://redis.googlecode.com/files/redis-2.6.4.tar.gz
$ tar -xvf redis-2.6.4.tar.gz -C ./
$ cd redis-2.6.4
$ make
$ make test
$ make install
$ mkdir /etc/redis
$ cp /data/programfiles/redis-2.6.4/redis.conf /etc/redis/
$ cp /data/programfiles/redis-2.6.4/src/redis-server /etc/init.d/redis-server
$ /etc/init.d/redis-server /etc/redis/redis.conf
- if following error, see FAQ 5
which: no tclsh8.5 in (/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/geffzhang/bin)
You need 'tclsh8.5' in order to run the Redis test
Make[1]: *** [test] error 1
make[1]: Leaving directory ‘/data/program files/redis-2.6.4/src’
Make: *** [test] error 2!
reference:git
$ yum -y install git
1.download
# centos
$ wget https://go.googlecode.com/files/go1.2.linux-amd64.tar.gz
$ tar -xvf go1.2.linux-amd64.tar.gz
$ cp -R go /usr/local/
2.golang env
modify ~/.profile
$ vim ~/.profile
# append
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
export GOPATH=/data/apps/go
$ source /etc/profile
1.download gopush-cluster
$ go get -u github.com/Terry-Mao/gopush-cluster
$ go get -u github.com/Terry-Mao/goconf
$ go get -u github.com/garyburd/redigo/redis
$ go get -u code.google.com/p/go.net/websocket
$ go get -u launchpad.net/gozk/zookeeper
*if following error, see FAQ 1
go: missing Mercurial command. See http://golang.org/s/gogetcmd
package code.google.com/p/go.net/websocket: exec: "hg": executable file not found in $PATH
*if following error, see FAQ 2
go: missing Bazaar command. See http://golang.org/s/gogetcmd
package launchpad.net/gozk/zookeeper: exec: "bzr": executable file not found in $PATH
*if following error, see FAQ 3
launchpad.net/gozk/zookeeper
../zk.go:15:23: error: zookeeper.h: No such file or directory
2.install message,comet,web node
$ cd $GOPATH/src/github.com/Terry-Mao/gopush-cluster/message
$ go install
$ cp message.conf $GOPATH/bin/
$ cd ../comet/
$ go install
$ cp comet-example.conf /data/apps/go/bin/
$ cd ../web/
$ go install
$ cp web.conf /data/apps/go/bin/
All done!!!
$ cd /$GOPATH/bin
$ nohup ./message -c message.conf &
$ nohup ./comet -c comet-example.conf &
$ nohup ./web -c web.conf &
*if following error, FAQ 4
error while loading shared libraries: libzookeeper_mt.so.2: cannot open shared object file: No such file or directory
1.push public message
$ curl -d "test2" http://localhost:8091/admin/push/public?expire=600
succeed response:{"msg":"ok","ret":0} 2.push private message
$ curl -d "test" http://localhost:8091/admin/push?key=Terry-Mao\&expire=600\&gid=0
succeed response:{"msg":"ok","ret":0} 3.get offline message open http://localhost:8090/msg/get?key=Terry-Mao&mid=1&pmid=0 in browser succeed response:
{
"data":{
"msgs":[
"{"msg":"test","expire":1391943609703654726,"mid":13919435497036558}"
],
"pmsgs":[
"{"msg":"test2","expire":1391943637016665915,"mid":13919435770166656}"
]
},
"msg":"ok",
"ret":0
}
4.get node address open http://localhost:8090/server/get?key=Terry-Mao&proto=2 in browser succeed response:
{
"data":{
"server":"localhost:6969"
},
"msg":"ok",
"ret":0
}
java: gopush-cluster-sdk
ios: GoPushforIOS
javascript: gopush-cluster-javascript-sdk
message
internal
1.install hg
$ wget http://mercurial.selenic.com/release/mercurial-1.4.1.tar.gz
$ tar -xvf mercurial-1.4.1.tar.gz
$ cd mercurial-1.4.1
$ make
$ make install
- if error couldn`t find ‘Python.h’
$ yum -y install python-devel
- if error:couldn`t find libraries
$ export PYTHONPATH=/usr/local/lib64/python2.6/site-packages
2.install bzr
$ yum install bzr.x86_64
3.modify gozk
$ vim $GOPATH/src/launchpad.net/gozk/zookeeper/zk.go
# find this line
# cgo CFLAGS: -I/usr/include/c-client-src -I/usr/include/zookeeper
# change include path
# cgo CFLAGS: -I/usr/local/include/zookeeper
4.error:libzookeeper_mt.so.2 can not found
$ export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
$ sudo ldconfig
5.install tcl8.5
$ cd /data/programfiles
$ wget http://downloads.sourceforge.net/tcl/tcl8.5.10-src.tar.gz
$ tar -xvf tcl8.5.10-src.tar.gz -C ./
$ cd tcl8.5.10
$ cd unix
$ ./configure
$ make
$ make install
TODO