diff --git a/modules/gopush/Puppetfile b/modules/gopush/Puppetfile new file mode 100644 index 00000000..2f8b2bdc --- /dev/null +++ b/modules/gopush/Puppetfile @@ -0,0 +1,7 @@ +mod 'cargomedia/helper', + :git => 'git@github.com:cargomedia/puppet-packages.git', + :path => 'modules/helper' + +mod 'cargomedia/monit', + :git => 'git@github.com:cargomedia/puppet-packages.git', + :path => 'modules/monit' diff --git a/modules/gopush/manifests/core/cometd.pp b/modules/gopush/manifests/core/cometd.pp new file mode 100644 index 00000000..a546d0c0 --- /dev/null +++ b/modules/gopush/manifests/core/cometd.pp @@ -0,0 +1,29 @@ +define gopush::core::cometd ( + $port_ws = 6968, + $port_tcp = 6969, + $port_rpc = 6970, + $bind_ip = undef, + $zoo_comet_path = '/gopush-cluster-comet', + $zoo_msg_path = '/gopush-cluster-message', + $zoo_host = 'localhost:2181' +) { + + require 'gopush' + + $daemon = 'gpcomet' + $instance_name = "${daemon}_${name}" + + file { + "/etc/gopush/${instance_name}.conf": + ensure => file, + content => template('gopush/cometd/conf'), + mode => '0644', + owner => 'gopush', + group => 'gopush', + notify => Service[$instance_name]; + } + -> + + gopush::core::service {$instance_name: } + +} diff --git a/modules/gopush/manifests/core/msgd.pp b/modules/gopush/manifests/core/msgd.pp new file mode 100644 index 00000000..3fd4ff56 --- /dev/null +++ b/modules/gopush/manifests/core/msgd.pp @@ -0,0 +1,24 @@ +define gopush::core::msgd ( + $port = 8170, + $bind_ip = undef +) { + + require 'gopush' + + $daemon = 'gpmsg' + $instance_name = "${daemon}_${name}" + + file { + "/etc/gopush/${instance_name}.conf": + ensure => file, + content => template('gopush/msgd/conf'), + mode => '0644', + owner => 'gopush', + group => 'gopush', + notify => Service[$instance_name]; + } + -> + + gopush::core::service {$instance_name: } + +} diff --git a/modules/gopush/manifests/core/service.pp b/modules/gopush/manifests/core/service.pp new file mode 100644 index 00000000..c7f06ad4 --- /dev/null +++ b/modules/gopush/manifests/core/service.pp @@ -0,0 +1,21 @@ +define gopush::core::service { + + file { + "/etc/init.d/${name}": + ensure => file, + content => template('gopush/init'), + mode => '0755', + owner => 'gopush', + group => 'gopush', + notify => Service[$name]; + } + -> + + helper::service {$name: } + + @monit::entry {$name: + content => template('gopush/monit'), + require => Service[$name], + } + +} diff --git a/modules/gopush/manifests/core/webd.pp b/modules/gopush/manifests/core/webd.pp new file mode 100644 index 00000000..1e5a96e4 --- /dev/null +++ b/modules/gopush/manifests/core/webd.pp @@ -0,0 +1,24 @@ +define gopush::core::webd ( + $port = 8080, + $bind_ip = undef +) { + + require 'gopush' + + $daemon = 'gpweb' + $instance_name = "${daemon}_${name}" + + file { + "/etc/gopush/${instance_name}.conf": + ensure => file, + content => template('gopush/webd/conf'), + mode => '0644', + owner => 'gopush', + group => 'gopush', + notify => Service[$instance_name]; + } + -> + + gopush::core::service {$instance_name: } + +} diff --git a/modules/gopush/manifests/init.pp b/modules/gopush/manifests/init.pp new file mode 100644 index 00000000..47e43ab0 --- /dev/null +++ b/modules/gopush/manifests/init.pp @@ -0,0 +1,30 @@ +class gopush ( + $version = '1.0-commit' +) { + + user {'gopush': + ensure => present, + system => true, + } + + file { + '/etc/gopush': + ensure => directory, + mode => '0644', + owner => 'gopush', + group => 'gopush'; + + '/var/run/gopush': + ensure => directory, + mode => '0644', + owner => 'gopush', + group => 'gopush'; + } + -> + + helper::script {'install gopush-cluster': + content => template('gopush/install.sh'), + unless => "test -x /usr/bin/gpcomet && /usr/bin/gpcomet -v | grep 'go${version}'", + } + +} diff --git a/modules/gopush/manifests/role/comet.pp b/modules/gopush/manifests/role/comet.pp new file mode 100644 index 00000000..9d843016 --- /dev/null +++ b/modules/gopush/manifests/role/comet.pp @@ -0,0 +1,13 @@ +class gopush::role::comet ( + $port_ws = 6968, + $port_tcp = 6969, + $port_rpc = 6970 +) { + + gopush::core::cometd {'comet': + port_ws => $port_ws, + port_tcp => $port_tcp, + port_rpc => $port_rpc, + } + +} diff --git a/modules/gopush/manifests/role/message.pp b/modules/gopush/manifests/role/message.pp new file mode 100644 index 00000000..786e2a7d --- /dev/null +++ b/modules/gopush/manifests/role/message.pp @@ -0,0 +1,9 @@ +class gopush::role::message ( + $port = 8170 +) { + + gopush::core::msgd {'message': + port => $port, + } + +} diff --git a/modules/gopush/manifests/role/web.pp b/modules/gopush/manifests/role/web.pp new file mode 100644 index 00000000..31524dca --- /dev/null +++ b/modules/gopush/manifests/role/web.pp @@ -0,0 +1,9 @@ +class gopush::role::web ( + $port = 8080 +) { + + gopush::core::webd {'web': + port => $port, + } + +} diff --git a/modules/gopush/spec/role-web/manifest.pp b/modules/gopush/spec/role-web/manifest.pp new file mode 100644 index 00000000..3d1f836c --- /dev/null +++ b/modules/gopush/spec/role-web/manifest.pp @@ -0,0 +1,5 @@ +node default { + + class {'gopush::role::web': } + +} diff --git a/modules/gopush/spec/role-web/spec.rb b/modules/gopush/spec/role-web/spec.rb new file mode 100644 index 00000000..3248bee6 --- /dev/null +++ b/modules/gopush/spec/role-web/spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe command('sleep 15') do + it { should return_exit_status 0 } +end diff --git a/modules/gopush/spec/webd/manifest.pp b/modules/gopush/spec/webd/manifest.pp new file mode 100644 index 00000000..5ba400a6 --- /dev/null +++ b/modules/gopush/spec/webd/manifest.pp @@ -0,0 +1,7 @@ +node default { + + gopush::core::webd {'web': + port => 8081 + } + +} diff --git a/modules/gopush/spec/webd/spec.rb b/modules/gopush/spec/webd/spec.rb new file mode 100644 index 00000000..3248bee6 --- /dev/null +++ b/modules/gopush/spec/webd/spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe command('sleep 15') do + it { should return_exit_status 0 } +end diff --git a/modules/gopush/templates/cometd/conf b/modules/gopush/templates/cometd/conf new file mode 100644 index 00000000..0cf743fc --- /dev/null +++ b/modules/gopush/templates/cometd/conf @@ -0,0 +1,231 @@ +# Comet configuration file example + +# Note on units: when memory size is needed, it is possible to specify +# it in the usual form of 1k 5GB 4M and so forth: +# +# 1kb => 1024 bytes +# 1mb => 1024*1024 bytes +# 1gb => 1024*1024*1024 bytes +# +# units are case insensitive so 1GB 1Gb 1gB are all the same. + +# Note on units: when time duration is needed, it is possible to specify +# it in the usual form of 1s 5M 4h and so forth: +# +# 1s => 1000 * 1000 * 1000 nanoseconds +# 1m => 60 seconds +# 1h => 60 minutes +# +# units are case insensitive so 1h 1H are all the same. + +[base] +# If the master process is run as root, then comet will setuid()/setgid() +# to USER/GROUP. If GROUP is not specified, then comet uses the same name as +# USER. By default it's nobody user and nobody or nogroup group. +user nobody + +# When running daemonized, Comet writes a pid file in +# /tmp/gopush-cluster-comet.pid by default. You can specify a custom pid file +# location here. +pidfile /tmp/gopush-cluster-comet.pid + +# Sets the maximum number of CPUs that can be executing simultaneously. +# This call will go away when the scheduler improves. By default the number of +# logical CPUs is set. +# +# maxproc 4 + +# By default comet listens for connections from all the network interfaces +# available on the server on 6968 port. It is possible to listen to just one or +# multiple interfaces using the "websocket.bind" configuration directive, +# followed by one or more IP addresses and port. +# +# Examples: +# +# Note this directive is only support "websocket" protocol +# websocket.bind 192.168.1.100:6968,10.0.0.1:6968 +# websocket.bind 127.0.0.1:6968 +# websocket.bind 0.0.0.0:6968 +websocket.bind localhost:6968 + +# By default comet listens for connections from all the network interfaces +# available on the server on 6969 port. It is possible to listen to just one or +# multiple interfaces using the "tcp.bind" configuration directive, followed by +# one or more IP addresses and port. +# +# Examples: +# +# Note this directive is only support "tcp" protocol +# tcp.bind 192.168.1.100:6969,10.0.0.1:6969 +# tcp.bind 127.0.0.1:6969 +# tcp.bind 0.0.0.0:6969 +tcp.bind localhost:6969 + +# This is used by rpc listen for internal protocol. +# By default comet admin listens for connections from local interfaces on 6970 +# port. It's not safty for listening internet IP addresses. +# +# Examples: +# +# rpc.bind 192.168.1.100:6970,10.0.0.1:6970 +# rpc.bind 127.0.0.1:6970 +# rpc.bind 0.0.0.0:6970 +rpc.bind localhost:6970 + +# This is used by comet service profiling (pprof). +# By default comet pprof listens for connections from local interfaces on 6971 +# port. It's not safty for listening internet IP addresses. +# +# Examples: +# +# pprof.bind 192.168.1.100:6971,10.0.0.1:6971 +# pprof.bind 127.0.0.1:6971 +# pprof.bind 0.0.0.0:6971 +pprof.bind localhost:6971 + +# This is used by comet service get stat info by http. +# By default comet pprof listens for connections from local interfaces on 6972 +# port. It's not safty for listening internet IP addresses. +# +# Examples: +# +# stat.bind 192.168.1.100:6971,10.0.0.1:6971 +# stat.bind 127.0.0.1:6971 +# stat.bind 0.0.0.0:6971 +stat.bind localhost:6972 + +# The working directory. +# +# The log will be written inside this directory, with the filename specified +# above using the 'logfile' configuration directive. +# +# Note that you must specify a directory here, not a file name. +dir ./ + +################################## ZOOKEEPER ################################## + +# The zookeeper cluster section. When comet start, it will register data in the +# zookeeper cluster and create a ephemeral node. When comet died, the node will +# drop by zookeeper cluster. So we can use the feature implement node failover. +[zookeeper] +# Comet create ephemeral node at the specified root path. +# +# Note the path must start with "/". +comet.path /gopush-cluster-comet + +# Set the node name of comet in zookeeper cluster. The default node name is +# node1, you must ensure the unique node name in the gopush cluster. +# Or you can make the same node name comet instance a slave of working one. +comet.node node1 + +# Comet get message rpc info from message path +# +# Note the path must start with "/". +message.path /gopush-cluster-message + +# Zookeeper cluster addresses. Mutiple address split by a ",". +# Examples: +# +# addr 192.168.1.100:2181,10.0.0.1:2181 +# addr 127.0.0.1:2181 +addr localhost:2181 + +# Zookeeper cluster session idle timeout seconds. Zookeeper will close the +# connection after a client is idle for N seconds. +# Examples: +# +# timeout 30s +# timeout 15s +timeout 30s + +################################## RPC ######################################## + +[rpc] +# Comet do a ping RPC call to test the rpc host available every N seconds. +ping 1s + +# If rpc host down, comet will retry connect to rpc host every N seconds. +retry 1s + +################################## CHANNELS ################################### + +[channel] +# SO_SNDBUF and SO_RCVBUF are options to adjust the normal buffer sizes +# allocated for output and input buffers, respectively. The buffer size may +# be increased for high-volume connections, or may be decreased to limit the +# possible backlog of incoming data. The system places an absolute limit on +# these values. +# +# Sets the maximum socket send buffer in bytes. The kernel doubles +# this value (to allow space for bookkeeping overhead) when it is set using +# setsockopt(2). The default value is set by the +# /proc/sys/net/core/wmem_default file and the maximum allowed value is set by +# the /proc/sys/net/core/wmem_max file. The minimum (doubled) value for this +# option is 2048. +sndbuf.size 2048 + +# Sets the maximum socket receive buffer in bytes. The kernel doubles this +# value (to allow space for bookkeeping overhead) when it is set using +# setsockopt(2). The default value is set by the +# /proc/sys/net/core/rmem_default file, and the maximum allowed value is set by +# the /proc/sys/net/core/rmem_max file. The minimum (doubled) value +# for this option is 256. +rcvbuf.size 256 + +# Comet support "tcp" and "websocket" push protocol. +# +# Examples +# proto tcp +# proto tcp,websocket +proto tcp,websocket + +# bufio.Reader cache instance for tcp cmd parsing, suggest the CPUs number. +# +# Note this directive is only support "tcp" protocol +# bufio.instance 4 + +# bufio.Reader cache number every instance. +# +# Note this directive is only support "tcp" protocol +bufio.num 128 + +# TCP keepalive. +# +# If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence +# of communication. This is useful for two reasons: +# +# 1) Detect dead peers. +# 2) Take the connection alive from the point of view of network +# equipment in the middle. +# +# On Linux, the specified value (in seconds) is the period used to send ACKs. +# Note that to close the connection the double of the time is needed. +# On other kernels the period depends on the kernel configuration. +# +# A reasonable value for this option is 60 seconds. +tcp.keepalive no + +# Max subscribers per channel. The same key subscribers limit by it. +maxsubscriber 64 + +# Every user per channel, For performance reason, Comet split channels into +# N buckets. Suggest the CPUs number. +# bucket 16 + +# Comet need auth or not, if yes client must send a token to the comet to verify +# that has rights to access comet service. +auth no + +# Message buffer cache num, if exceed this value, the comet will close the +# connection. +msgbuf.num 120 + +################################## INCLUDES ################################### + +# Include one or more other config files here. This is useful if you +# have a standard template that goes to all comet server but also need +# to customize a few per-server settings. Include files can include +# other files, so use this wisely. +# +# include /path/to/local.conf +# include /path/to/other.conf diff --git a/modules/gopush/templates/init b/modules/gopush/templates/init new file mode 100644 index 00000000..e6fb916c --- /dev/null +++ b/modules/gopush/templates/init @@ -0,0 +1,266 @@ +#!/bin/sh +# +# init.d script with LSB support. +# +# Copyright (c) 2007 Javier Fernandez-Sanguino +# +# This is free software; you may redistribute it and/or modify +# it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2, +# or (at your option) any later version. +# +# This is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License with +# the Debian operating system, in /usr/share/common-licenses/GPL; if +# not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA +# +### BEGIN INIT INFO +# Provides: <%= @instance_name %> +# Required-Start: $network $local_fs $remote_fs +# Required-Stop: $network $local_fs $remote_fs +# Should-Start: $named +# Should-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: An object/document-oriented database +# Description: MongoDB is a high-performance, open source, schema-free +# document-oriented data store that's easy to deploy, manage +# and use. It's network accessible, written in C++ and offers +# the following features: +# +# * Collection oriented storage - easy storage of object- +# style data +# * Full index support, including on inner objects +# * Query profiling +# * Replication and fail-over support +# * Efficient storage of binary data including large +# objects (e.g. videos) +# * Automatic partitioning for cloud-level scalability +# +# High performance, scalability, and reasonable depth of +# functionality are the goals for the project. +### END INIT INFO + +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +DAEMON=/usr/bin/<%= @daemon %> +DESC=database + +NAME=<%= @instance_name %> +# Defaults. Can be overridden by the /etc/default/$NAME +# Other configuration options are located in $CONF file. See here for more: +# http://dochub.mongodb.org/core/configurationoptions +CONF=/etc/mongodb/<%= @instance_name %>.conf +PIDFILE=/var/run/<%= @instance_name %>.pid +ENABLE_MONGOD=yes + +# Include mongodb defaults if available +if [ -f /etc/default/$NAME ] ; then + . /etc/default/$NAME +fi + +# Handle NUMA access to CPUs (SERVER-3574) +# This verifies the existence of numactl as well as testing that the command works +NUMACTL_ARGS="--interleave=all" +if which numactl >/dev/null 2>/dev/null && numactl $NUMACTL_ARGS ls / >/dev/null 2>/dev/null +then + NUMACTL="`which numactl` -- $NUMACTL_ARGS" + DAEMON_OPTS=${DAEMON_OPTS:-"--config $CONF"} +else + NUMACTL="" + DAEMON_OPTS="-- "${DAEMON_OPTS:-"--config $CONF"} +fi + +if test ! -x $DAEMON; then + echo "Could not find $DAEMON" + exit 0 +fi + +if test "x$ENABLE_MONGOD" != "xyes"; then + exit 0 +fi + +. /lib/lsb/init-functions + +STARTTIME=1 +DIETIME=10 # Time to wait for the server to die, in seconds + # If this value is set too low you might not + # let some servers to die gracefully and + # 'restart' will not work + +DAEMONUSER=${DAEMONUSER:-mongodb} + +set -e + +running_pid() { +# Check if a given process pid's cmdline matches a given name + pid=$1 + name=$2 + [ -z "$pid" ] && return 1 + [ ! -d /proc/$pid ] && return 1 + cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1` + # Is this the expected server + [ "$cmd" != "$name" ] && return 1 + return 0 +} + +running() { +# Check if the process is running looking at /proc +# (works for all users) + + # No pidfile, probably no daemon present + [ ! -f "$PIDFILE" ] && return 1 + pid=`cat $PIDFILE` + running_pid $pid $DAEMON || return 1 + return 0 +} + +start_server() { + # Recommended ulimit values for mongod or mongos + # See http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings + # + ulimit -f unlimited + ulimit -t unlimited + ulimit -v unlimited + ulimit -n 64000 + ulimit -m unlimited + + # In dash, ulimit takes -p for maximum user processes + # In bash, it's -u + if readlink /proc/$$/exe | grep -q dash + then + ulimit -p 32000 + else + ulimit -u 32000 + fi + + # Start the process using the wrapper + start-stop-daemon --background --start --quiet --pidfile $PIDFILE \ + --make-pidfile --chuid $DAEMONUSER \ + --exec $NUMACTL $DAEMON $DAEMON_OPTS + errcode=$? + return $errcode +} + +stop_server() { +# Stop the process using the wrapper + start-stop-daemon --stop --quiet --pidfile $PIDFILE \ + --retry 300 \ + --user $DAEMONUSER \ + --exec $DAEMON + errcode=$? + return $errcode +} + +force_stop() { +# Force the process to die killing it manually + [ ! -e "$PIDFILE" ] && return + if running ; then + kill -15 $pid + # Is it really dead? + sleep "$DIETIME"s + if running ; then + kill -9 $pid + sleep "$DIETIME"s + if running ; then + echo "Cannot kill $NAME (pid=$pid)!" + exit 1 + fi + fi + fi + rm -f $PIDFILE +} + + +case "$1" in + start) + log_daemon_msg "Starting $DESC" "$NAME" + # Check if it's running first + if running ; then + log_progress_msg "apparently already running" + log_end_msg 0 + exit 0 + fi + if start_server ; then + # NOTE: Some servers might die some time after they start, + # this code will detect this issue if STARTTIME is set + # to a reasonable value + [ -n "$STARTTIME" ] && sleep $STARTTIME # Wait some time + if running ; then + # It's ok, the server started and is running + log_end_msg 0 + else + # It is not running after we did start + log_end_msg 1 + fi + else + # Either we could not start it + log_end_msg 1 + fi + ;; + stop) + log_daemon_msg "Stopping $DESC" "$NAME" + if running ; then + # Only stop the server if we see it running + errcode=0 + stop_server || errcode=$? + log_end_msg $errcode + else + # If it's not running don't do anything + log_progress_msg "apparently not running" + log_end_msg 0 + exit 0 + fi + ;; + force-stop) + # First try to stop gracefully the program + $0 stop + if running; then + # If it's still running try to kill it more forcefully + log_daemon_msg "Stopping (force) $DESC" "$NAME" + errcode=0 + force_stop || errcode=$? + log_end_msg $errcode + fi + ;; + restart|force-reload) + log_daemon_msg "Restarting $DESC" "$NAME" + errcode=0 + stop_server || errcode=$? + # Wait some sensible amount, some server need this + [ -n "$DIETIME" ] && sleep $DIETIME + start_server || errcode=$? + [ -n "$STARTTIME" ] && sleep $STARTTIME + running || errcode=$? + log_end_msg $errcode + ;; + status) + + log_daemon_msg "Checking status of $DESC" "$NAME" + if running ; then + log_progress_msg "running" + log_end_msg 0 + else + log_progress_msg "apparently not running" + log_end_msg 1 + exit 1 + fi + ;; + # MongoDB can't reload its configuration. + reload) + log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon" + log_warning_msg "cannot re-read the config file (use restart)." + ;; + + *) + N=/etc/init.d/$NAME + echo "Usage: $N {start|stop|force-stop|restart|force-reload|status}" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/modules/gopush/templates/install.sh b/modules/gopush/templates/install.sh new file mode 100644 index 00000000..f6eb0686 --- /dev/null +++ b/modules/gopush/templates/install.sh @@ -0,0 +1,2 @@ +#!/bin/sh -e + diff --git a/modules/gopush/templates/monit b/modules/gopush/templates/monit new file mode 100644 index 00000000..40086a2d --- /dev/null +++ b/modules/gopush/templates/monit @@ -0,0 +1,4 @@ +check process <%= @instance_name %> with pidfile /var/run/<%= @instance_name %>.pid + start program = "/etc/init.d/<%= @instance_name %> start" + stop program = "/etc/init.d/<%= @instance_name %> stop" + if failed port <%= @port %> with timeout 45 seconds for 2 cycles then restart diff --git a/modules/gopush/templates/msgd/conf b/modules/gopush/templates/msgd/conf new file mode 100644 index 00000000..ee58c946 --- /dev/null +++ b/modules/gopush/templates/msgd/conf @@ -0,0 +1,139 @@ +# Message configuration file example + +# Note on units: when memory size is needed, it is possible to specify +# it in the usual form of 1k 5GB 4M and so forth: +# +# 1kb => 1024 bytes +# 1mb => 1024*1024 bytes +# 1gb => 1024*1024*1024 bytes +# +# units are case insensitive so 1GB 1Gb 1gB are all the same. + +# Note on units: when time duration is needed, it is possible to specify +# it in the usual form of 1s 5M 4h and so forth: +# +# 1s => 1000 * 1000 * 1000 nanoseconds +# 1m => 60 seconds +# 1h => 60 minutes +# +# units are case insensitive so 1h 1H are all the same. + +[base] +# Message service tcp listen and server on this address, +# default tcp listen localhost:8070 +# Examples: +# +# rpc.bind 192.168.1.100:8070,10.0.0.1:8070 +# rpc.bind 127.0.0.1:8070 +# rpc.bind 0.0.0.0:8070 +rpc.bind localhost:8070 + +# If the master process is run as root, then message will setuid()/setgid() +# to USER/GROUP. If GROUP is not specified, then message uses the same name as +# USER. By default it's nobody user and nobody or nogroup group. +user nobody + +# When running daemonized, Message writes a pid file in +# /tmp/gopush-cluster-message.pid by default. You can specify a custom pid file +# location here. +pidfile /tmp/gopush-cluster-message.pid + +# Sets the maximum number of CPUs that can be executing simultaneously. +# This call will go away when the scheduler improves. By default the number of +# logical CPUs is set. +# +# maxproc 4 + +# The working directory. +# +# Note that you must specify a directory here, not a file name. +dir ./ + +# This is used by message service profiling (pprof). +# By default message pprof listens for connections from local interfaces on 8170 +# port. It's not safty for listening internet IP addresses. +# +# Examples: +# +# pprof.bind 192.168.1.100:8170,10.0.0.1:8170 +# pprof.bind 127.0.0.1:8170 +# pprof.bind 0.0.0.0:8170 +pprof.bind localhost:8170 + +[storage] +# Storage type, Support: redis, mysql. We suggest use redis, cause mysql is low +# efficency. Now, only support to run one of both in the same time +type redis + +[redis] +# Close connections after remaining idle for this duration. If the value +# is zero, then idle connections are not closed. Applications should set +# the timeout to a value less than the server's timeout. +timeout 28800s + +# Maximum number of idle connections in the pool. +idle 100 + +# Maximum number of connections allocated by the pool at a given time. +# When zero, there is no limit on the number of connections in the pool. +active 300 + +# Max quantity of stored message for each key, default 20 +store 20 + +[redis.source] +# The format like "NodeName IP:Port", NodeName was specified by Comet service. +# If there are multiple nodes, then configure following +# node1 IP1:Port1 +# node2 IP2:Port2 +# node3 IP3:Port3 +node1 localhost:6379 + +[mysql] +# Delete all of expired message loop time interval +clean 1h + +[mysql.source] +# Database source. +# For example with the following +node1 test:test@(192.168.1.2:3306)/gopush?parseTime=true&loc=Local&charset=utf8 +node2 test:test@(192.168.1.3:3306)/gopush?parseTime=true&loc=Local&charset=utf8 +node3 test:test@(192.168.1.4:3306)/gopush?parseTime=true&loc=Local&charset=utf8 + +################################## ZOOKEEPER ################################## + +# The zookeeper cluster section. When message start, it will register data in +# the zookeeper cluster and create a ephemeral node. When message died, the +# node will drop by zookeeper cluster. So we can use the feature implement node +# failover. +[zookeeper] +# Zookeeper cluster addresses. Mutiple address split by a ",". +# Examples: +# +# addr 192.168.1.100:2181,10.0.0.1:2181 +# addr 127.0.0.1:2181 +addr localhost:2181 + +# Zookeeper cluster session idle timeout seconds. Zookeeper will close the +# connection after a client is idle for N seconds, Zookeeper will send heartbeat +# after timeout / 2 second. +# Examples: +# +# timeout 30s +# timeout 15s +timeout 30s + +# message create ephemeral node at the specified root path. +# +# Note the path must start with "/". +path /gopush-cluster-message + +################################## INCLUDES ################################### + +# Include one or more other config files here. This is useful if you +# have a standard template that goes to all comet server but also need +# to customize a few per-server settings. Include files can include +# other files, so use this wisely. +# +# include /path/to/local.conf +# include /path/to/other.conf diff --git a/modules/gopush/templates/webd/conf b/modules/gopush/templates/webd/conf new file mode 100644 index 00000000..613df2fd --- /dev/null +++ b/modules/gopush/templates/webd/conf @@ -0,0 +1,115 @@ +# Web configuration file example + +# Note on units: when memory size is needed, it is possible to specify +# it in the usual form of 1k 5GB 4M and so forth: +# +# 1kb => 1024 bytes +# 1mb => 1024*1024 bytes +# 1gb => 1024*1024*1024 bytes +# +# units are case insensitive so 1GB 1Gb 1gB are all the same. + +# Note on units: when time duration is needed, it is possible to specify +# it in the usual form of 1s 5M 4h and so forth: +# +# 1s => 1000 * 1000 * 1000 nanoseconds +# 1m => 60 seconds +# 1h => 60 minutes +# +# units are case insensitive so 1h 1H are all the same. + +[base] +# Web service http listen and server on this address, default localhost:8090 +# +# Examples +# tcp.bind localhost:8090 +# tcp.bind 192.168.1.100:8090,192.168.1.101:8090 +# tcp.bind 0.0.0.0:8090 +tcp.bind localhost:8090 + +# Web service http listen and server on this address, default localhost:8091 +# mainly servers for internal admin +# Examples +# tcp.bind localhost:8091 +# tcp.bind 192.168.1.100:8091,192.168.1.101:8091 +# tcp.bind 0.0.0.0:8091 +admin.bind localhost:8091 + +# Sets the maximum number of CPUs that can be executing simultaneously. +# This call will go away when the scheduler improves. By default the number of +# logical CPUs is set. +# +# maxproc 4 + +# This is used by web service profiling (pprof). +# By default web pprof listens for connections from local interfaces on 8190 +# port. It's not safty for listening internet IP addresses. +# +# Examples: +# +# pprof.bind 192.168.1.100:8190,10.0.0.1:8190 +# pprof.bind 127.0.0.1:8190 +# pprof.bind 0.0.0.0:8190 +pprof.bind localhost:8190 + +# If the master process is run as root, then web will setuid()/setgid() +# to USER/GROUP. If GROUP is not specified, then web uses the same name as +# USER. By default it's nobody user and nobody or nogroup group. +user nobody + +# When running daemonized, Web writes a pid file in +# /tmp/gopush-cluster-web.pid by default. You can specify a custom pid file +# location here. +pidfile /tmp/gopush-cluster-web.pid + +# The working directory. +# +# The log will be written inside this directory, with the filename specified +# above using the 'logfile' configuration directive. +# +# Note that you must specify a directory here, not a file name. +# dir ./ + +# Network router, now only support CN, if need not router then can annotate +# router CN + +[res] +# QQWry.dat ip library resource path. +# You could get QQWry.dat from github.com/thinkboy/go-qqwry +# qqwry.path /tmp/QQWry.dat + +[zookeeper] +# The provided servers parameter may include multiple server addresses, separated +# by commas, so that the client will automatically attempt to connect +# to another server if one of them stops working for whatever reason. +# Used for exmple following +# addr IP1:Port1,IP2:Port2,IP3:Port3 +addr localhost:2181 + +# The timeout parameter, given in nanoseconds, allows controlling +# the amount of time the zookeeper connection can stay unresponsive before the +# zookeeper server will be considered problematic. +timeout 30s + +# The root path of all nodes that Comet mounted in zookeeper,default /gopush-cluster-comet +comet.path /gopush-cluster-comet + +# The root path of all nodes that message mounted in zookeeper,default /gopush-cluster +message.path /gopush-cluster-message + +[rpc] +# It will ping rpc service per ping time to confirm connecting is alive +# ping 1s + +# Interval time of every reconnection +# retry 3s + +################################## INCLUDES ################################### + +# Include one or more other config files here. This is useful if you +# have a standard template that goes to all comet server but also need +# to customize a few per-server settings. Include files can include +# other files, so use this wisely. +# +# include /path/to/local.conf +# include /path/to/other.conf