Services/PythonServer: Difference between revisions
Tarek.ziade (talk | contribs) (Created page with "The Python Sync Server is composed of four parts: * ''server-core'': library containing various helpers. * ''server-storage'': the storage server. * ''server-reg'': the user r...") |
Tarek.ziade (talk | contribs) No edit summary |
||
(6 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
* ''server-storage'': the storage server. | * ''server-storage'': the storage server. | ||
* ''server-reg'': the user registration/management server. | * ''server-reg'': the user registration/management server. | ||
* ''server-full'': a server that reunites the | * ''server-full'': a server that reunites the storage and the reg servers so you can run everything in a single box. | ||
you can run everything in a single box. | |||
The Continuous Integration server is located here: https://hudson.mozilla.org/job/Sync | |||
Line 24: | Line 25: | ||
* sqlite3 | * sqlite3 | ||
* mercurial | * mercurial | ||
* the python-profiler package under Debian or | * the python-profiler package under Debian or Ubuntu | ||
Ubuntu | |||
= Installing the full server = | = Installing the full server = | ||
Line 37: | Line 36: | ||
This command will create an isolated Python environment and pull all the | This command will create an isolated Python environment and pull all the | ||
required dependencies in it. A ''bin'' directory is created and contains a | 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. | server. | ||
Line 50: | Line 49: | ||
and the user APIs. Once the server is launched, you can point your Firefox Sync | and the user APIs. Once the server is launched, you can point your Firefox Sync | ||
to "http://localhost:5000" and make sure it works. | to "http://localhost:5000" and make sure it works. | ||
= Running behind Apache = | = Running behind Apache = | ||
Line 58: | Line 56: | ||
implementation (WSGI-based): | implementation (WSGI-based): | ||
* Apache + mod_wsgi | |||
* lighttpd + flup + fcgi | |||
* Nginx + uWsgi or GUnicorn or Spawn | |||
Here's an example of an Apache setup: | Here's an example of an Apache setup: | ||
Line 84: | Line 82: | ||
sure this file loads the right .ini file. | sure this file loads the right .ini file. | ||
TBD: SSL example | |||
= Sync Configuration File = | = Sync Configuration File = | ||
TBD | TBD |
Latest revision as of 13:03, 19 October 2010
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
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