README.md 3.81 KB
Newer Older
1
2
3
4
5
# Project Setup 


To clone this repo use the command: 
```
6
$ git clone https://gitlab.rc.uab.edu/mmoo97/flask_user_reg.git
7
8
```
## Prerequisites 
9
### Clone Repository
10
- Ensure `pip` is installed (see: https://packaging.python.org/guides/installing-using-pip-and-virtualenv/ ).
11
12
13
  - Check if installed by typing `$ pip` for Mac/Linux or `$ py` for Windows.
  - Mac/Linux: Install pip using `$ python -m pip install --user --upgrade pip`.
  - Windows: Install pip using `$ py -m pip install --upgrade pip`
14
15
- 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.
16
  - Note, this project requires a virtual environment running python2 (2.7.x)
17
- Ensure Flask and other dependencies are installed using the following commands:
18
```
19
$ cd ~/your/repo/path/flask_user_reg
20
$ git checkout version-1b-openstack-rabbitmq
21
22
$ source venv/bin/activate
$ pip install -r requirements.txt
23
```
24
- Note, to install flask in your own `$HOME` use `pip install --user Flask`.
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
### Install RabbitMQ
(Reference: [here](https://www.rabbitmq.com/tutorials/tutorial-four-python.html))
- Install RabbitMQ server on the host machine. ([Installation Guide](https://www.rabbitmq.com/download.html))
  - #### Mac/Linux
    - `$ brew update`
    - `$ brew install rabbitmq`
    - it is recommended that you add the following line to your `.bash_profile`:  
 `export PATH=$PATH:/usr/local/opt/rabbitmq/sbin`.
    - Start server using the command `$ rabbitmq-server`. (Note, this implementation assumes RabbitMQ is running on localhost on standard port 5672)
  - #### Windows
    - Download the installer from [here](https://github.com/rabbitmq/rabbitmq-server/releases) and run.
    - Post install, the server should be running. To check, run `$ rabbitmqctl.bat status`.
  - #### CentOS 7
    - First, import signing key using `$ rpm --import https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc`
    - Next, install Erlang using `$ yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm`
    - Finally, install RabbitMq using `$ yum install rabbitmq-server-3.8.2-1.el8.noarch.rpm`
    - The server is not started as a daemon by default when the RabbitMQ server package is installed. To start the 
    daemon by default when the system boots, as an administrator run: `$ chkconfig rabbitmq-server on`.
    - As an administrator, start and stop the server as usual: <br/>`/sbin/service rabbitmq-server start` 
    <br/> `/sbin/service rabbitmq-server stop`
 - Add the user "reggie" using the command `$ rabbitmqctl add_user reggie reggie`.
   - The current configuration assumes the following username password combination. To change the password, type 
   `$ rabbitmqctl change_password reggie <new_password>`. 
   - Note that rabbitmqctl may require sudo permissions and that changing the password will require a password
   change in the credentials within `test_producer.py` and `base_consumer.py` as well.

## Test RabbitMQ
For a simple example on the functionality of RabbitMQ, do the following:
- Open up a new ssh terminal and ssh into your ohpc node and, in a separate window, ssh into your ood node.
- Once in, ensure your rabbitmq server is running using the command ` `
- Additionally, ensure you have a rabbitmq user configured with the username and password as `reggie`.
- 

```
# Run consumer on ohpc node
$ python base_consumer.py ohpc
```
 You will notice that the script is awaiting a message to display.
 To produce a message, run the following on the ood node terminal session:
 ```
$ python test_producer.py ohpc 
```
67

68
69
70
71
You should now see that the message has been sent and displayed on the ohpc node.
- **Note,** that the `test_producer.py` script is identical to the code within the `ingest_data()` function in `run.py`.