Skip to content
Snippets Groups Projects
README.md 2.12 KiB
Newer Older
nick's avatar
nick committed
# Project Setup 


To clone this repo use the command: 
```
$ git clone https://gitlab.rc.uab.edu/mmoo97/flask_user_reg.git
nick's avatar
nick committed

```
## Prerequisites 
Mitchell Moore's avatar
Mitchell Moore committed
###Clone Repository
Mitchell Moore's avatar
Mitchell Moore committed
- Ensure `pip` is installed (see: https://packaging.python.org/guides/installing-using-pip-and-virtualenv/ ).
- Ensure you have created a [virtual environment](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments) 
called `venv` setup within the cloned project.
  - Note, this project requires a virtual environment running python2 (2.7)
- Ensure Flask and other dependencies are installed using the following commands:
nick's avatar
nick committed
```
Mitchell Moore's avatar
Mitchell Moore committed
$ git checkout version-1b-local-rabbitmq
$ cd ~/your/repo/path/flask_user_reg
$ source venv/bin/activate
$ pip install -r requirements.txt
nick's avatar
nick committed
```
- Note, to install flask in your own `$HOME` use `pip install --user Flask`.
Mitchell Moore's avatar
Mitchell Moore committed
### RabbitMQ
Mitchell Moore's avatar
Mitchell Moore committed
(Reference [Tutorial Part Four](https://www.rabbitmq.com/tutorials/tutorial-four-python.html))
Mitchell Moore's avatar
Mitchell Moore committed
- Install RabbitMQ server on the host machine. (Tutorials [here](https://www.rabbitmq.com/download.html).)
  - Additionally, if on a Mac, it is recommended that you add the following line to your `.bash_profile`:  
 `export PATH=$PATH:/usr/local/opt/rabbitmq/sbin`.
- Run the command `$ rabbitmq-server`. (Note, this implementation assumes RabbitMQ is running on localhost on standard port 5672)
nick's avatar
nick committed

Mitchell Moore's avatar
Mitchell Moore committed
## Test RabbitMQ
Mitchell Moore's avatar
Mitchell Moore committed
For a simple example on the functionality of RabbitMQ, do the following:
- Open 4 separate terminal sessions whilst in the `flask_user_reg` directory and enter one of the following commands per window:

```
# Run in First 
$ python ohpc_consumer.py

# Run in Second
$ python ood_consumer.py

# Run in Third 
$ python message_manager.py

```
 - You will notice that the scripts are all awaiting a message to be sent to them.
 - To produce a message run the following in the forth terminal session:
 ```
# Run in Forth Window
$ python test_producer.py
```
- Notice that the producer sends only to the specified `ood` and `ohpc` consumers and not to the `message_manager` consumer.
  - **Note,** that the `test_producer.py` script is identical to the code within the `ingest_data()` function in `run.py`.