This repository has been archived by the owner on Nov 21, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
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 8f6d041
Showing
8 changed files
with
249 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,21 @@ | ||
.hg* | ||
*.pyc | ||
*.mako.py | ||
lib | ||
include | ||
bin | ||
man | ||
.channel | ||
deps | ||
*.egg-info | ||
*.swp | ||
html | ||
doc/build | ||
\.coverage | ||
*~ | ||
._build.etag | ||
_build.py.bak* | ||
test | ||
nosetests.xml | ||
build | ||
cover |
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 @@ | ||
recursive-include etc *.ini |
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,53 @@ | ||
DEPS = https://github.com/mozilla-services/tokenserver,https://github.com/mozilla-services/server-syncstorage | ||
VIRTUALENV = virtualenv | ||
PYTHON = bin/python | ||
NOSE = bin/nosetests -s | ||
TESTS = deps/https:/github.com/mozilla-services/server-syncstorage/syncstorage/tests | ||
BUILDAPP = bin/buildapp | ||
BUILDRPMS = bin/buildrpms | ||
PYPI = http://pypi.python.org/simple | ||
PYPIOPTIONS = -i $(PYPI) | ||
CHANNEL = dev | ||
INSTALL = bin/pip install | ||
INSTALLOPTIONS = -U -i $(PYPI) | ||
|
||
ifdef PYPIEXTRAS | ||
PYPIOPTIONS += -e $(PYPIEXTRAS) | ||
INSTALLOPTIONS += -f $(PYPIEXTRAS) | ||
endif | ||
|
||
ifdef PYPISTRICT | ||
PYPIOPTIONS += -s | ||
ifdef PYPIEXTRAS | ||
HOST = `python -c "import urlparse; print urlparse.urlparse('$(PYPI)')[1] + ',' + urlparse.urlparse('$(PYPIEXTRAS)')[1]"` | ||
|
||
else | ||
HOST = `python -c "import urlparse; print urlparse.urlparse('$(PYPI)')[1]"` | ||
endif | ||
INSTALLOPTIONS += --install-option="--allow-hosts=$(HOST)" | ||
|
||
endif | ||
|
||
INSTALL += $(INSTALLOPTIONS) | ||
|
||
|
||
.PHONY: all build update test | ||
|
||
|
||
all: build | ||
|
||
build: | ||
$(VIRTUALENV) --no-site-packages --distribute . | ||
$(INSTALL) Distribute | ||
$(INSTALL) MoPyTools | ||
$(INSTALL) Nose | ||
$(BUILDAPP) -c $(CHANNEL) $(PYPIOPTIONS) $(DEPS) | ||
for DEP in `echo $(DEPS) | tr ',' ' '`; do $(INSTALL) -r ./deps/$$DEP/$(CHANNEL)-reqs.txt; done | ||
$(INSTALL) https://github.com/mozilla-services/mozservices/zipball/master | ||
|
||
update: | ||
$(BUILDAPP) -c $(CHANNEL) $(PYPIOPTIONS) $(DEPS) | ||
|
||
test: | ||
$(PYTHON) -c "import M2Crypto" | ||
$(NOSE) $(TESTS) |
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,78 @@ | ||
Experimental Run-Your-Own Sync2.0 Server | ||
======================================== | ||
|
||
This is an experimental codebase for running a standalone Sync2.0 server. | ||
It may be useful for third-party developers who want to preview and prepare | ||
for the upcoming Sync2.0 protocol and related API changes (see | ||
http://docs.services.mozilla.com/storage/apis-2.0.html for the details). | ||
|
||
This repo is likely to be retired and replaced with something else as | ||
development progresses. It really is only for early adopters to try things | ||
out and give us feedback. You have been warned... | ||
|
||
|
||
Getting Started | ||
--------------- | ||
|
||
Take a checkout of this repository, then run "make build" to pull in the | ||
necessary dependencies:: | ||
|
||
$ git clone https://github.com/mozilla-services/server-full2 | ||
$ cd server-full2 | ||
$ make build | ||
|
||
To sanity-check that things got installed correctly, do the following:: | ||
|
||
$ make test | ||
|
||
This may report that M2Crypto did not build correctly. If so, try symlinking | ||
in the copy from your system python like so:: | ||
|
||
$ # Remove the broken local install of M2Crypto | ||
$ rm -rf ./lib/*/site-packages/M2Crypto* | ||
$ # Install m2crypto using your system package manager. | ||
$ sudo apt-get install python-m2crypto | ||
... | ||
$ # Find the directory containing M2Crypto on your system. | ||
$ python -c 'import M2Crypto; print M2Crypto.__file__' | ||
/usr/lib/python2.7/dist-packages/M2Crypto/__init__.pyc | ||
$ # Symlink all M2Crypto files into into your virtualenv | ||
$ ln -s /usr/lib/python2.7/dist-packages/M2Crypto* ./lib/*/site-packages/ | ||
$ # Now the tests should pass. | ||
$ make test | ||
|
||
Now you can run the server via paster:: | ||
|
||
$ ./bin/paster serve ./etc/production.ini | ||
|
||
This should start a server on http://localhost:5000/. There is no | ||
Sync2.0 client build into firefox yet, but you can test it out by running | ||
the functional testsuite against your server:: | ||
|
||
$ ./bin/python ./deps/https:/github.com/mozilla-services/server-syncstorage/syncstorage/tests/functional/test_storage.py --use-token-server --audience="http://localhost:5000" http://localhost:5000/1.0/sync/2.0 | ||
|
||
If that reports no errors, congratulations! You have a basic working install | ||
of the Sync2.0 server. | ||
|
||
|
||
Customization | ||
------------- | ||
|
||
All customization of the server can be done by editing the file | ||
"./etc/production.ini", which contains lots of comments to help you on | ||
your way. Things you might like to change include: | ||
|
||
* The client-visible hostname for your server. Edit the "service_entry" | ||
key under the [tokenserver] section, the "audiences" key under the | ||
[browserid] section, and the corresponding entry in the file | ||
"./etc/secrets". | ||
|
||
* The database in which to store sync data. Edit the various settings | ||
under the [storage] section. | ||
|
||
|
||
Questions, Feedback | ||
------------------- | ||
|
||
- IRC channel: #sync. See http://irc.mozilla.org/ | ||
- Mailing list: https://mail.mozilla.org/admin/services-dev |
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,53 @@ | ||
[server:main] | ||
use = egg:Paste#http | ||
host = 0.0.0.0 | ||
port = 5000 | ||
|
||
# The top-level application stitches together the tokenserver and syncstorage | ||
# apps to run in a single server's namespace. | ||
[composite:main] | ||
use = egg:Paste#urlmap | ||
/ = tokenserver | ||
/service/sync = syncstorage | ||
|
||
[app:tokenserver] | ||
use = egg:tokenserver | ||
|
||
[app:syncstorage] | ||
use = egg:SyncStorage | ||
|
||
# Tokenserver configuration sections. | ||
# | ||
# You need to specify the client-visible URL of your | ||
[tokenserver] | ||
backend = tokenserver.assignment.fixednode.DefaultNodeAssignmentBackend | ||
applications = sync-2.0 | ||
secrets_file = ./etc/secrets | ||
service_entry = http://localhost:5000 | ||
|
||
[endpoints] | ||
sync-2.0 = {node}/service/sync/2.0/{uid} | ||
|
||
[browserid] | ||
backend = tokenserver.verifiers.LocalVerifier | ||
audiences = http://localhost:5000 | ||
|
||
[storage] | ||
backend = syncstorage.storage.sql.SQLStorage | ||
sqluri = sqlite:////tmp/tests.db | ||
standard_collections = false | ||
use_quota = true | ||
quota_size = 5242880 | ||
pool_size = 100 | ||
pool_recycle = 3600 | ||
reset_on_return = true | ||
create_tables = true | ||
batch_size = 25 | ||
|
||
[who.plugin.macauth] | ||
secrets_file = ./etc/secrets | ||
|
||
[metlog] | ||
backend = mozsvc.metrics.MetlogPlugin | ||
enabled = True | ||
sender_class = metlog.senders.StdOutSender |
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 @@ | ||
http://localhost:5000,12345:OHSOSECRET |
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 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
# You can obtain one at http://mozilla.org/MPL/2.0/. | ||
from setuptools import setup | ||
|
||
install_requires = ['PasteScript', 'tokenserver', 'SyncStorage'] | ||
|
||
entry_points = """ | ||
[paste.app_factory] | ||
main = syncserver2:make_app | ||
""" | ||
|
||
setup(name='SyncServer2', version="2.0", packages=['syncserver2'], | ||
install_requires=install_requires, entry_points=entry_points) |
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,28 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
# You can obtain one at http://mozilla.org/MPL/2.0/. | ||
""" | ||
Application entry point. | ||
""" | ||
import os | ||
from logging.config import fileConfig | ||
from ConfigParser import NoSectionError | ||
from paste.deploy import loadapp | ||
|
||
# Set the egg cache to a place where the webserver can write | ||
os.environ['PYTHON_EGG_CACHE'] = '/tmp/python-eggs' | ||
|
||
# Load the .ini file from production place, unless specified in environment. | ||
|
||
ini_file = os.path.join(os.path.dirname(__file__), | ||
'..', 'etc', 'production.ini') | ||
ini_file = os.path.abspath(os.environ.get('SYNCSERVER2_INI_FILE', ini_file)) | ||
|
||
# Set up logging from the config file. | ||
try: | ||
fileConfig(ini_file) | ||
except NoSectionError: | ||
pass | ||
|
||
# Load the application callable using paste. | ||
application = loadapp('config:%s' % ini_file) |