forked from jrconlin/moz_push
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6af1c38
Showing
31 changed files
with
2,897 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
VIRTUALENV = virtualenv | ||
PYTHON = bin/python | ||
PIP = bin/pip | ||
EZ = bin/easy_install | ||
|
||
# Broker configuration | ||
BROKER_VHOST = / | ||
BROKER_ADMIN_USER = admin | ||
BROKER_ADMIN_PASSWORD = admin | ||
|
||
.PHONY: all env rabbitmq | ||
|
||
all: env rabbitmq | ||
|
||
env: | ||
rm -rf bin build deps include lib lib64 | ||
$(VIRTUALENV) --no-site-packages --distribute . | ||
$(PYTHON) setup.py develop | ||
mkdir -p deps | ||
cd deps && hg clone http://hg.mozilla.org/services/server-core | ||
cd deps/server-core && ../../$(PYTHON) setup.py develop | ||
|
||
clean-env: | ||
rm -rf bin build deps include lib lib64S | ||
|
||
zeromq: | ||
# you may need to run sudo ldconfig if this reports that libzmq is not found | ||
|
||
rabbitmq: | ||
mkdir -p bin | ||
cd bin && \ | ||
curl --silent http://www.rabbitmq.com/releases/rabbitmq-server/v2.3.1/rabbitmq-server-generic-unix-2.3.1.tar.gz | tar -zvx | ||
mv bin/rabbitmq_server-2.3.1 bin/rabbitmq-server | ||
ln -s -f $(CURDIR)/etc/rabbitmq/rabbitmq-env bin/rabbitmq-server/sbin/rabbitmq-env | ||
cd bin/rabbitmq-server/sbin && \ | ||
./rabbitmq-server -detached && sleep 3s && \ | ||
./rabbitmqctl add_user $(BROKER_ADMIN_USER) $(BROKER_ADMIN_PASSWORD) && \ | ||
./rabbitmqctl set_admin $(BROKER_ADMIN_USER) && \ | ||
./rabbitmqctl set_permissions -p $(BROKER_VHOST) admin ".*" ".*" ".*" && \ | ||
./rabbitmqctl clear_admin guest && \ | ||
./rabbitmqctl set_permissions -p $(BROKER_VHOST) guest "" "" ".*" && \ | ||
./rabbitmqctl stop | ||
cd bin/rabbitmq-server/plugins && \ | ||
curl -o "#1.ez" "http://www.rabbitmq.com/releases/plugins/v2.3.1/{mochiweb,webmachine,amqp_client,rabbitmq-mochiweb,rabbitmq-management-agent,rabbitmq-management}-2.3.1.ez" | ||
|
||
clean-rabbitmq: | ||
-./bin/rabbitmq-server/sbin/rabbitmqctl -q stop | ||
rm -rf var bin/rabbitmq-server | ||
|
||
clean: clean-rabbitmq clean-env | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
PUSH NOTIFICATIONS | ||
|
||
Requirements: | ||
------------- | ||
Make sure you have the following software already | ||
installed before proceeding: | ||
|
||
- Erlang runtime R14B+ or newer | ||
- Make | ||
- Python 2.6 (with virtualenv installed) | ||
|
||
Note to users of RHEL 5 and derived distributions (e.g. CentOS 5): | ||
Due to the EPEL package update policy, EPEL 5 contains Erlang version | ||
R12B-5, which is relatively old. rabbitmq-server supports R12B-5, | ||
but performance may be lower than for more recent Erlang versions, | ||
and certain non-core features are not supported (SSL support, | ||
HTTP-based plugins). Therefore, we recommend that you install the most | ||
recent stable version of Erlang. The easiest way to do this is to use a | ||
package repository provided for this purpose by the owner of the EPEL | ||
Erlang package. Enable it by invoking (as root): | ||
|
||
wget -O /etc/yum.repos.d/epel-erlang.repo http://repos.fedorapeople.org/repos/peter/erlang/epel-erlang.repo | ||
|
||
and then install or update erlang with yum install erlang. | ||
|
||
Note: RabbitMQ was selected to address the message persistance issues. Sadly, | ||
ZeroMQ does not offer message persistance across app/server reboots. | ||
|
||
|
||
Installation: | ||
------------- | ||
Make sure any currently running rabbitmq server (if there | ||
is one) is stopped before continuing. | ||
|
||
After downloading the repository for the first time, | ||
cd into the directory and run make. | ||
|
||
This will do the following: | ||
- Create a virtual python environment | ||
- Install required python packages into this environment | ||
- Fetch the rabbitmq server and set up a configuration | ||
- Install rabbitmq plugins | ||
|
||
After make completes all of these tasks, if it hasn't | ||
terminated with an error then everything should be set. | ||
|
||
The default RabbitMQ configuration is designed not to | ||
interfere with any other rabbitmq server installed on the | ||
system (so long as a previous installation has not set any | ||
environment variables used by the server). | ||
|
||
In addition, you'll need to start the rabbitmq server and do the following: | ||
* Create a new Exchange called "incoming_exchange" (type: direct, durable, VHost: /) | ||
* | ||
|
||
|
||
|
||
|
||
Running the Server: | ||
------------------- | ||
The message broker (used by the server to route messages) | ||
and the HTTP server must be started separately. The steps | ||
are (starting from the root project directory) | ||
|
||
1. Run "./bin/rabbitmq-server/sbin/rabbitmq-server" | ||
to start the message broker. | ||
To shut it down at any point in the future, run | ||
"./bin/rabbitmq-server/sbin/rabbitmqctl stop" | ||
|
||
2. Run "bin/paster serve development.ini" to start the | ||
POST Office and Client Agent HTTP server. | ||
|
||
Monitoring the Server: | ||
---------------------- | ||
You can monitor the RabbitMQ server once it has started by | ||
navigating to http://localhost:55672/mgmt in a browser (if | ||
you're using the out-of-the-box configuration). This takes | ||
you to the RabbitMQ Management web console, which itself is | ||
relatively self-explanatory. Note that this should really | ||
only be used for development purposes, as having the | ||
management console running can reduce througput. | ||
You can read more about the Management plugin here: | ||
http://www.rabbitmq.com/management.html | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
[server:main] | ||
use = egg:Paste#http | ||
host = 0.0.0.0 | ||
port = 8000 | ||
use_threadpool = True | ||
threadpool_workers = 60 | ||
|
||
[composite:main] | ||
use = egg:Paste#urlmap | ||
/1.0/notification = post_office | ||
/1.0/ = client_agent | ||
|
||
[app:post_office] | ||
use = egg:NotifServer#post_office_router | ||
configuration = file:%(here)s/etc/rabbitmq.conf | ||
broker_host = localhost | ||
|
||
broker_amqp_port = 5672 | ||
broker_username = admin | ||
broker_password = admin | ||
broker_virtual_host = / | ||
incoming_exchange_name = incoming_exchange | ||
notifs_queue_name = notifications | ||
|
||
[app:client_agent] | ||
use = egg:NotifServer#client_agent | ||
filter-with = basic_auth | ||
configuration = file:%(here)s/etc/rabbitmq.conf | ||
|
||
[filter:basic_auth] | ||
use = egg:NotifServer#basic_auth | ||
realm = Mozilla Push Notifications | ||
configuration = file:%(here)s/etc/rabbitmq.conf | ||
|
||
# | ||
# logging | ||
# | ||
[loggers] | ||
keys = root,auth,clientagent,messagestorage,postoffice,pika,paste | ||
|
||
[handlers] | ||
keys = global,notifserver,pika | ||
|
||
[formatters] | ||
keys = generic | ||
|
||
[logger_root] | ||
level = WARNING | ||
handlers = global | ||
|
||
[logger_auth] | ||
qualname = auth | ||
level = DEBUG | ||
handlers = notifserver | ||
propagate = 0 | ||
|
||
[logger_clientagent] | ||
qualname = clientagent | ||
level = DEBUG | ||
handlers = notifserver | ||
propagate = 0 | ||
|
||
[logger_messagestorage] | ||
qualname = messagestorage | ||
level = DEBUG | ||
handlers = notifserver | ||
propagate = 0 | ||
|
||
[logger_postoffice] | ||
qualname = postoffice | ||
level = DEBUG | ||
handlers = notifserver | ||
propagate = 0 | ||
|
||
[logger_pika] | ||
qualname = pika | ||
level = WARNING | ||
handlers = pika | ||
propagate = 0 | ||
|
||
[logger_paste] | ||
qualname = paste | ||
level = INFO | ||
handlers = notifserver | ||
propagate = 0 | ||
|
||
[handler_global] | ||
class = StreamHandler | ||
args = (sys.stderr,) | ||
level = DEBUG | ||
formatter = generic | ||
|
||
[handler_notifserver] | ||
class = StreamHandler | ||
args = (sys.stderr,) | ||
level = DEBUG | ||
formatter = generic | ||
|
||
[handler_pika] | ||
class = StreamHandler | ||
args = (sys.stderr,) | ||
level = WARNING | ||
formatter = generic | ||
|
||
[formatter_generic] | ||
format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s | ||
datefmt = %Y-%m-%d %H:%M:%S |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[auth] | ||
backend = sql | ||
sqluri = sqlite:////tmp/test.db | ||
pool_size = 100 | ||
pool_recycle = 3600 | ||
|
||
[messagestorage] | ||
backend = memory | ||
host = DONTUSETHISITWONTWORK | ||
amqp_port = 5672 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[auth] | ||
backend=services.auth.dummy.DummyAuth | ||
|
||
[notifserver] | ||
templates = /home/jconlin/src/mozilla/notifications/server/notifserver/templates/ | ||
backend = notifserver.storage.rabbitmq.RabbitMQStorage | ||
username=admin | ||
password=admin | ||
host=push1.mtv1.dev.svc.mozilla.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
[DEFAULT] | ||
debug = False | ||
translogger = False | ||
profile = False | ||
|
||
[server:main] | ||
use = egg:Paste#http | ||
host = 0.0.0.0 | ||
port = 8000 | ||
use_threadpool = True | ||
threadpool_workers = 60 | ||
|
||
[app:main] | ||
use = egg:NotifServer | ||
configuration = file://%(here)s/notifserver.ini | ||
|
||
[cef] | ||
use = false | ||
file = syslog | ||
vendor = mozilla | ||
version = 0 | ||
device_version = 1.3 | ||
product = weave | ||
|
||
[logging] | ||
enabled = true | ||
server_log = /tmp/notifs.log | ||
level = DEBUG | ||
|
||
[loggers] | ||
keys = root,app | ||
|
||
[handlers] | ||
keys = file01 | ||
|
||
[formatters] | ||
keys = format01 | ||
|
||
[logger_root] | ||
level = DEBUG | ||
handlers = file01 | ||
|
||
[logger_app] | ||
level = DEBUG | ||
qualname = app | ||
handlers = file01 | ||
propgate = 0 | ||
|
||
[handler_file01] | ||
class = FileHandler | ||
level = DEBUG | ||
formatter = format01 | ||
args = ('/tmp/notifs.log', 'w') | ||
|
||
[formatter_format01] | ||
format = %(name)s: %(asctime)s %(levelname)s %(message)s | ||
datefmt = | ||
class = logging.Formatter | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[auth] | ||
backend = sql | ||
sqluri = sqlite:////tmp/test.db | ||
pool_size = 100 | ||
pool_recycle = 3600 | ||
|
||
[messagestorage] | ||
backend = rabbitmq | ||
username = admin | ||
password = admin | ||
host = localhost | ||
amqp_port = 5672 | ||
http_port = 55672 | ||
virtual_host = / | ||
incoming_exchange_name = incoming_exchange | ||
routing_queue_name = wait_queue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/sh | ||
# This script is used as a replacement for the rabbitmq-env script | ||
# that is included in the sbin directory of rabbitmq-server. It | ||
# Allows us to specify the location of the environment configuration | ||
# file ourselves, rather than it defaulting to searching the global | ||
# /etc/rabbitmq folder for one. It expects that the script it is | ||
# replacing is located in <PROJECT_DIR>/bin/rabbitmq-server/sbin, and | ||
# that the rabbitmq.conf file it points to is located in | ||
# <PROJECT_DIR>/etc/rabbitmq | ||
|
||
# Determine where this script is really located | ||
SCRIPT_PATH="$0" | ||
while [ -h "$SCRIPT_PATH" ] ; do | ||
FULL_PATH=`readlink -f $SCRIPT_PATH 2>/dev/null` | ||
if [ "$?" != "0" ]; then | ||
REL_PATH=`readlink $SCRIPT_PATH` | ||
if expr "$REL_PATH" : '/.*' > /dev/null; then | ||
SCRIPT_PATH="$REL_PATH" | ||
else | ||
SCRIPT_PATH="`dirname "$SCRIPT_PATH"`/$REL_PATH" | ||
fi | ||
else | ||
SCRIPT_PATH=$FULL_PATH | ||
fi | ||
done | ||
|
||
SCRIPT_DIR=`dirname $SCRIPT_PATH` | ||
RABBITMQ_HOME="${SCRIPT_DIR}/.." | ||
[ "x" = "x$HOSTNAME" ] && HOSTNAME=`env hostname` | ||
NODENAME=rabbit@${HOSTNAME%%.*} | ||
|
||
# Modified location of conf file | ||
LOCAL_CONFIG="${RABBITMQ_HOME}/../../etc/rabbitmq/rabbitmq.conf" | ||
|
||
# Load configuration from the rabbitmq.conf file | ||
[ -f "${LOCAL_CONFIG}" ] && . "${LOCAL_CONFIG}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Configuration file for RabbitMQ startup scripts. | ||
# These are the environment variables used by the | ||
# scripts to initialize the server. | ||
# MNESIA_BASE, LOG_BASE, and CONFIG_FILE are set | ||
# to point to directories within the notifications | ||
# project directory. Unless you know what you're | ||
# doing, don't change these. | ||
MNESIA_BASE="${RABBITMQ_HOME}/../../var/lib/rabbitmq/mnesia" | ||
LOG_BASE="${RABBITMQ_HOME}/../../var/log/rabbitmq" | ||
CONFIG_FILE="${RABBITMQ_HOME}/../../etc/rabbitmq/rabbitmq" | ||
NODENAME=bunny | ||
NODE_IP_ADDRESS=0.0.0.0 | ||
NODE_PORT=5672 | ||
|
Oops, something went wrong.