Services/PythonServer
The Python Sync Server is composed of four parts:
- server-core: library containing various helpers.
- server-storage: the storage server.
- server-reg: the user registration/management server.
- server-full: a server that reunites the storage and the reg servers so you can run everything in a single box.
The Continuous Integration server is located here: https://hudson.mozilla.org/job/Sync
Contents
Prerequisites
The various parts are using Python 2.6 and virtualenv. Make sure your system have them. Or install them:
The rest of this document makes the assumption that you are under Linux or Mac OS X. I'll create an installation script for Windows if there's some interest.
To run the server, you will also need to have these packages installed:
- make
- sqlite3
- mercurial
- the python-profiler package under Debian or Ubuntu
Installing the full server
It is recommended to install the full server. Get the latest version at https://hg.mozilla.org/services/server-full and run this command:
$ make build
This command will create an isolated Python environment and pull all the required dependencies in it. A bin directory is created and contains a paster command that can be used to run the server, using the built-in web server.
Running options are kept in an ini-like file that is passed to the command:
$ bin/paster serve development.ini Starting server in PID 29951. serving on 0.0.0.0:5000 view at http://127.0.0.1:5000
By default the server is configured to use a SQLite database for the storage and the user APIs. Once the server is launched, you can point your Firefox Sync to "http://localhost:5000" and make sure it works.
Running behind Apache
The built-in server is not to be used if you want to set up a production server. You can use different web servers that are compatible with the implementation (WSGI-based):
- Apache + mod_wsgi
- lighttpd + flup + fcgi
- Nginx + uWsgi or GUnicorn or Spawn
Here's an example of an Apache setup:
<Directory /path/to/sync> Order deny,allow Allow from all </Directory> <VirtualHost *:80> ServerName example.com DocumentRoot /path/to/sync WSGIProcessGroup sync WSGIDaemonProcess sync user=sync group=sync processes=2 threads=25 WSGIPassAuthorization On WSGIScriptAlias / /path/to/sync/sync.wsgi CustomLog /var/log/apache2/example.com-access.log combined ErrorLog /var/log/apache2/example.com-error.log </VirtualHost>
This configuration will use the sync.wsgi file located in the project. Make sure this file loads the right .ini file.
TBD: SSL example
Sync Configuration File
TBD