This document helps in setting up development environment to run the
userdirectory
application.
After cloning the web-app-short-course
, copy
src/runtime/config/custom-config.org.sample
to
src/runtime/config/custom-config.org
If the command
which mysql
returns nothing, then mysql
is not installed.
/etc/init.d/mysql status
If this returns something like mysql start/running, process
<pid>
, then mysql
is running. Otherwise it is not
running and you will need to start it.
sudo /etc/init.d/mysql start
See https://support.rackspace.com/how-to/mysql-resetting-a-lost-mysql-root-password/
Note that the section “Stop and start the MySQL service” has a mistake: you need to start mysql; trying to stop it will give you an error. Simply ignore the stop command.
- First stop
mysql
:
sudo /etc/init.d/mysql stop
- Login to mysql
mysql -u <username> -p<password>
- Show all databases
show databases;
- If <userdirectory> database is not present, create it
create database userdirectory;
Exit our of the mysql console
Run make from web-app-short-course
directory to build the application. The
code gets tangled but the test cases will fail. This is because some of the
dependencies have not been set up. To insall the dependencies and run the
application, follow the steps listed below.
% make
- Create Virtual Environemnt in the
web-app-short-course
directory
virtualenv venv
- Activate the Virtual Environment
source venv/bin/activate
Install all the dependencies for running the user-directory
applciation.
The setup.py
script is in the build/code/deployment
directory
cd <path to build/code/deployment> directory python setup.py install
If below problem occurs (reference stackoverflow post)
oursqlx/oursql.c:8:22: fatal error: pyconfig.h: No such file or directory #include "pyconfig.h" ^ compilation terminated. error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Do the following
sudo su - apt-get install libmysqlclient-dev apt-get install python-dev
The variable SQLALCHEMY_DATABASE_URI
has to be set to proper value in
src/runtime/config/custom-config.org
so that the application can
use the database. In the example below, root
is the user and mysql
is
the password.
SQLALCHEMY_DATABASE_URI = 'mysql+oursql://root:mysql@localhost/userdirectory'
Set PYTHONPATH variable and export it to access python modules.
cd build/code/ export PYTHONPATH=${PWD}:$PYTHONPATH
Edit src/runtime/config/custom-config.org
to set CONSUMER_KEY
and
CONSUMER_SECRET
that were obtained from the previous step.
This is necessary for the current application to use Google OAUTH service.
CONSUMER_KEY = "<key>" CONSUMER_SECRET = "<key>"
The make
this time should pass. Change directory to web-app-short-course
and run make
.
% make
Edit build/code/runtime/config/config.py
and set admin-email
to
have a valid admin user when the web app launches.
# config.py
# ---------
admin_email = "<your google email id which was used to create OAuth credentials>"
Run build/code/deployment/db_setup.py
to insert roles and an admin user.
# db_setup.py
# -----------
cd build/code/deployment
python db_setup.py
The application can now be run from the build/code
directory
cd <path to build/code directory> unset http_proxy unset https_proxy python runtime/rest/app.py
The application is accessed at http://localhost:5000