Skip to content
Snippets Groups Projects
Commit 78b0237e authored by Mitchell Moore's avatar Mitchell Moore
Browse files

Merge branch 'update-README' into 'version-1b-local-rabbitmq'

Update readme

See merge request mmoo97/flask_user_reg!31
parents 45725d2c 6b1bf10f
No related branches found
No related tags found
2 merge requests!35Version 1b openstack rabbitmq,!31Update readme
......@@ -7,15 +7,47 @@ $ git clone https://gitlab.rc.uab.edu/mmoo97/flask_user_reg.git
```
## Prerequisites
###Clone Repository
- 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:
```
$ git checkout version-1b-local-rabbitmq
$ cd ~/your/repo/path/flask_user_reg
$ source venv/bin/activate
$ pip install -r requirements.txt
```
- Note, to install flask in your own `$HOME` use `pip install --user Flask`.
###RabbitMQ
- 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)
##Test RabbitMQ
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`.
\ No newline at end of file
import pika
import sys
# Begin RabbitMQ process.
connection = pika.BlockingConnection(
pika.ConnectionParameters(host='localhost'))
channel = connection.channel()
channel.exchange_declare(exchange='direct_logs', exchange_type='direct')
message = "Hey there" # todo: account info goes here
channel.basic_publish(
exchange='direct_logs', routing_key="ohpc", body=message)
print(" [x] Sent %r:%r" % ("ohpc", message))
channel.basic_publish(
exchange='direct_logs', routing_key="ood", body=message)
print(" [x] Sent %r:%r" % ("ood", message))
connection.close()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment