Skip to content

Latest commit

 

History

History
187 lines (151 loc) · 5.11 KB

run-userdirectory-in-development-environment.org

File metadata and controls

187 lines (151 loc) · 5.11 KB

WebApp (User Directory) Short Course

Introduction

This document helps in setting up development environment to run the userdirectory application.

Rename sample config files

After cloning the web-app-short-course, copy src/runtime/config/custom-config.org.sample to src/runtime/config/custom-config.org

Installation of Database

Checking if mysql is installed

If the command

which mysql

returns nothing, then mysql is not installed.

Installing mysql

Checking if installed version is running as a service

/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.

Starting mysql if it not running

sudo /etc/init.d/mysql start

Resetting the mysql password.

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

Creation of database

  1. Login to mysql
    mysql -u <username> -p<password>
        
  2. Show all databases
    show databases;
        
  3. If <userdirectory> database is not present, create it
    create database userdirectory;
        

    Exit our of the mysql console

Initial make

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

Creation of Virtual Environment

  • Create Virtual Environemnt in the web-app-short-course directory
virtualenv venv
  • Activate the Virtual Environment
source venv/bin/activate

Setting up dependencies

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

Set SQLALCHEMY_DATABASE_URI

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'

Export PYTHONPATH

Set PYTHONPATH variable and export it to access python modules.

cd build/code/
export PYTHONPATH=${PWD}:$PYTHONPATH

Configure OAuth for Application

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>"

Run Make again

The make this time should pass. Change directory to web-app-short-course and run make.

% make

Insert Dafault data

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

Run the application

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

Access the application

The application is accessed at http://localhost:5000