-
Notifications
You must be signed in to change notification settings - Fork 27
DEPRECATED Run A MapRoulette Development Server Locally
We are currently at MapRoulette 3 :)
This guide walks you through manually setting up MapRoulette on your local machine for development. If you want to deploy a server for testing or production, please see the deployment documentation
First we need to set up system level dependencies. This is different for Linux and OSX.
On a fresh Ubuntu 14.04 LTS (also successfully tested on 13.04 and 13.10):
sudo apt-get install software-properties-common python-software-properties postgresql-server-dev-all python-dev git virtualenvwrapper postgresql-client
See installation with Homebrew
For PostgreSQL, rely on Postgres.app - it contains recent versions of PostgreSQL and PostGIS and just works.
For easy access to the PostgreSQL related command line tools, add the following to your shell startup:
PATH=/Applications/Postgres93.app/Contents/MacOS/bin:${PATH}
As the postgres
user:
createuser -s -P osm
Enter the password osm
twice. On Mac, you can skip this step, as you will connect to the PostgreSQL database using your system account.
Now create the three databases for the production, test and dev environments:
createdb -O osm maproulette
createdb -O osm maproulette_test
createdb -O osm maproulette_dev
Again, on Mac, you don't need to specify ownership. Leave out the -O osm
.
Now you can switch back to a non-postgres user.
Add PostGIS extensions to the databases:
psql -h localhost -U osm -d maproulette -c 'CREATE EXTENSION postgis'
psql -h localhost -U osm -d maproulette_test -c 'CREATE EXTENSION postgis'
psql -h localhost -U osm -d maproulette_dev -c 'CREATE EXTENSION postgis'
If you have not used virtualenvwrapper
before, you should spawn a new shell at this point for the virtualenvwrapper
scripts to be sourced.
Set up the virtual environment and activate it:
mkvirtualenv maproulette
git clone https://github.com/osmlab/maproulette.git
cd maproulette/
pip install --editable .
Wait for things to be downloaded, compiled and moved into place. There will be warnings, but the process should end with a confirmation that a bunch of python modules were installed.
MapRoulette reads some of its configuration from an external configuration file. In a local test environment, it will look for a config.py
file in ~/.maproulette
Create a new directory ~/.maproulette
:
mkdir ~/.maproulette
Then copy the example config file to there, renaming it to config.py
:
cp config_example.py ~/.maproulette/config.py
Open that file and change where it says CHANGE THIS
. Save.
export FLASK_APP=maproulette
export FLASK_DEBUG=true
Now we're ready to generate the database tables from the model:
flask createdb
You may want to load some mock challenges and tasks:
flask createtestdata
The last step is to compile the client Javascript from the React JSX. For this you need react-tools
which is installed using npm. This step is optional if you will not be working on the client, having the Javascript available is strictly not necessary.
npm install -g react-tools
Then, you can either compile the JSX file once so as to have it available to the client:
cat /path/to/maproulette/jsx/maproulette.js | jsx > /path/to/maproulette/maproulette/static/js/maproulette.js
If you want to work on the client, you will probably want to make use of the watch mode that jsx
offers, so any change to the JSX file is picked up and the Javascript file recompiled:
jsx --watch /path/to/maproulette/jsx /path/to/maproulette/maproulette/static/js
Finally, run the server:
flask run
At this point you should see:
* Serving Flask app "maproulette"
* Forcing debug mode on
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger pin code: 306-242-102
And you should have a MapRoulette instance at http://localhost:5000/