11 Commits

Author SHA1 Message Date
Patrick McDonagh
51ec43b85d Adds admin user setup 2017-07-11 17:52:23 -05:00
Patrick McDonagh
13835dcfa4 Use MD file instead of TXT 2017-06-29 18:11:06 -05:00
Patrick McDonagh
b500baeaf1 Ignores unnecessary files in the repo 2017-05-25 15:03:07 -05:00
Patrick McDonagh
32b7a82886 Changes for case when no cards are in db 2017-05-03 13:38:17 -05:00
Patrick McDonagh
0e58c84c6a Changes for fixing Docker-Compose
Development uses localhost db
Instead of creating a separate network, just use the link parameter
2017-05-03 13:10:41 -05:00
Patrick McDonagh
d5ff30356a Adds a docker-compose file, fixes admin function 2017-05-02 17:52:44 -05:00
Patrick McDonagh
351e0674de Gets everything ready for docker 2017-05-02 17:35:29 -05:00
Patrick McDonagh
2be84b694b Adds docker file and mongo config 2017-05-02 15:14:00 -05:00
Patrick McDonagh
1cc1933df4 Moves supervisor.conf back and updates service 2017-05-02 10:59:52 -05:00
Patrick McDonagh
eeaef59d89 Moves supervisor.conf for use of HERE variable 2017-05-02 10:28:49 -05:00
Patrick McDonagh
58a84756ce Merge pull request #3 from Henry-Pump/optimize-time-series-data
Ignores more files, updates mongo URI, starts readme for installing
2017-05-02 10:20:38 -05:00
15 changed files with 140 additions and 31 deletions

4
.gitignore vendored
View File

@@ -3,3 +3,7 @@ env/*
pocwww.egg* pocwww.egg*
pocwww/__pycache__/* pocwww/__pycache__/*
pocwww.egg-info/* pocwww.egg-info/*
*.pyc
.idea/*
.idea/vcs.xml

22
Dockerfile Normal file
View File

@@ -0,0 +1,22 @@
FROM python:latest
COPY pocwww /root/www/pocwww
COPY setup.py /root/www/setup.py
COPY README.txt /root/www/README.txt
COPY CHANGES.txt /root/www/CHANGES.txt
COPY MANIFEST.in /root/www/MANIFEST.in
COPY generate_cert.sh /root/www/generate_cert.sh
RUN chmod +x /root/www/generate_cert.sh
RUN /root/www/generate_cert.sh
RUN pip3 install /root/www/
COPY production.ini /root/www/production.ini
# COPY development.ini /root/www/development.ini
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
EXPOSE 6543
CMD ["pserve", "/root/www/production.ini", "http_port=6543"]

32
README.md Normal file
View File

@@ -0,0 +1,32 @@
# Henry Pump POC Web Interface
## Installation
1. Install nginx, Python 2&3 & venv with ```sudo apt-get install nginx python python-pip python3 python3-venv python3-pip```
2. Cd into the pocwww directory, run ```python3 -m venv env``` to create the virtual environment.
3. Update the install of pip ```env/bin/pip install --upgrade pip setuptools```
4. Install the python module ```env/bin/pip install .```
5. Generate HTTPS keys
```
chmod +x generate_keys.sh
./generate_keys.sh
```
5. Test the web server ```env/bin/pserve production.ini http_port=8080```
6. Install supervisor ```pip install supervisor```
7. Configure supervisor service
```sudo cp supervisord.service /etc/systemd/system/```
8. Configure nginx
```
sudo cp poc.conf /etc/nginx/sites-available/
sudo rm /etc/nginx/sites/enabled/default
sudo ln -s /etc/nginx/sites-available/poc.conf /etc/nginx/sites-enabled/
sudo service nginx restart
```

View File

@@ -1,12 +0,0 @@
# Henry Pump POC Web Interface
## Installation
1. Install Python 3 & venv with `sudo apt-get install python3 python3-venv`
2. From the root of the POC-Java-www directory, run `python3 -m venv env` to create the virtual environment.
3. Update the install of pip `env/binpip install --upgrade pip setuptools`
4. Install the python module `env/bin/pip install .`
5. Test the web server `env/bin/pserve production.ini`

View File

@@ -19,7 +19,6 @@ pyramid.includes =
# debugtoolbar.hosts = 127.0.0.1 ::1 # debugtoolbar.hosts = 127.0.0.1 ::1
mongo_uri = mongodb://poc_www:HenryPump1903@localhost:27017/poc mongo_uri = mongodb://poc_www:HenryPump1903@localhost:27017/poc
# mongo_uri = mongodb://10.20.155.202:27017/poc
### ###

30
docker-compose.yml Normal file
View File

@@ -0,0 +1,30 @@
version : '2'
services:
mongo:
image: docker.henrypump.cloud/poc/mongodb-server
ports:
- "27017:27017"
# networks:
# poc:
# ipv4_address: 10.10.10.10
www:
image: docker.henrypump.cloud/poc/poc-java-www
ports:
- "8080:6543"
# networks:
# - poc
depends_on:
- mongo
links:
- mongo:mongodb
# networks:
# poc:
# driver: bridge
# driver_opts:
# com.docker.network.enable_ipv4: "true"
# ipam:
# driver: default
# config:
# - subnet: 10.10.10.0/24

View File

@@ -179,7 +179,6 @@ def main(global_config, **settings):
config.add_route('users_register', '/register', factory='pocwww.security.UserLoginFactory') config.add_route('users_register', '/register', factory='pocwww.security.UserLoginFactory')
config.add_route("users_json", "/json/users", factory='pocwww.security.UserLoginFactory') config.add_route("users_json", "/json/users", factory='pocwww.security.UserLoginFactory')
# POC Interface # POC Interface
config.add_route("poc_updateconfig_json", "/json/updateconfig", factory='pocwww.security.UserLoginFactory') config.add_route("poc_updateconfig_json", "/json/updateconfig", factory='pocwww.security.UserLoginFactory')
config.add_route("poc_shake_json", '/json/cmd/shake', factory='pocwww.security.UserLoginFactory') # Shake command is separate for allowing all access config.add_route("poc_shake_json", '/json/cmd/shake', factory='pocwww.security.UserLoginFactory') # Shake command is separate for allowing all access
@@ -189,8 +188,5 @@ def main(global_config, **settings):
config.add_route('poc_mode_json', '/json/mode', factory='pocwww.security.UserLoginFactory') config.add_route('poc_mode_json', '/json/mode', factory='pocwww.security.UserLoginFactory')
config.add_route('poc_setpoints', '/setpoints', factory='pocwww.security.UserLoginFactory') config.add_route('poc_setpoints', '/setpoints', factory='pocwww.security.UserLoginFactory')
config.scan() config.scan()
return config.make_wsgi_app() return config.make_wsgi_app()

View File

@@ -1,7 +0,0 @@
from pyramid.view import view_config
@view_config(route_name="admin", renderer="templates/admin.jinja2", permission="edit")
def admin_view(request):
address = get_poc_address(request) or 'localhost'
return {'navgroup': 'admin', 'pocIPAddress': address}

View File

@@ -24,10 +24,10 @@ def my_view(request):
for t in latesttag_agg: for t in latesttag_agg:
latest_tag_values.append(t) latest_tag_values.append(t)
latest_card = [] latest_card = None
try: try:
latest_card = list(request.db['cards'].find().sort("timestamp", -1).limit(1))[0] latest_card = list(request.db['cards'].find().sort("timestamp", -1).limit(1))[0]
except IndexError: except IndexError:
latest_card = [] latest_card = None
return {'project': 'POC Web Interface', 'navgroup': 'dashboard', 'tag_values': latest_tag_values, 'card': latest_card} return {'project': 'POC Web Interface', 'navgroup': 'dashboard', 'tag_values': latest_tag_values, 'card': latest_card}

View File

@@ -10,6 +10,12 @@ def get_poc_address(request):
return address return address
@view_config(route_name="admin", renderer="templates/admin.jinja2", permission="edit")
def admin_view(request):
address = get_poc_address(request) or 'localhost'
return {'navgroup': 'admin', 'pocIPAddress': address}
@view_config(route_name="poc_updateconfig_json", renderer="prettyjson", request_method='POST', permission="edit") @view_config(route_name="poc_updateconfig_json", renderer="prettyjson", request_method='POST', permission="edit")
def json_updateconfig(request): def json_updateconfig(request):
conv_to_float = [ conv_to_float = [

View File

@@ -57,7 +57,7 @@
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<h2 class="allcaps">Latest Card</h2> <h2 class="allcaps">Latest Card</h2>
{% if card is defined %} {% if card is mapping %}
<h3>{{card.timestamp | datetime('long')}}</h1> <h3>{{card.timestamp | datetime('long')}}</h1>
<canvas id="surfacecard" height="140"></canvas> <canvas id="surfacecard" height="140"></canvas>
<canvas id="downholecard" height="140"></canvas> <canvas id="downholecard" height="140"></canvas>

View File

@@ -10,7 +10,7 @@ pyramid.debug_authorization = false
pyramid.debug_notfound = false pyramid.debug_notfound = false
pyramid.debug_routematch = false pyramid.debug_routematch = false
pyramid.default_locale_name = en pyramid.default_locale_name = en
mongo_uri = mongodb://poc_www:HenryPump1903@localhost:27017/poc mongo_uri = mongodb://poc_www:HenryPump1903@mongodb:27017/poc
#---------- Pipeline Configuration ---------- #---------- Pipeline Configuration ----------
@@ -28,7 +28,7 @@ pipeline =
[server:main] [server:main]
use = egg:waitress#main use = egg:waitress#main
host = 127.0.0.1 host = 0.0.0.0
port = %(http_port)s port = %(http_port)s

View File

@@ -3,7 +3,7 @@ import os
from setuptools import setup, find_packages from setuptools import setup, find_packages
here = os.path.abspath(os.path.dirname(__file__)) here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, 'README.txt')) as f: with open(os.path.join(here, 'README.md')) as f:
README = f.read() README = f.read()
with open(os.path.join(here, 'CHANGES.txt')) as f: with open(os.path.join(here, 'CHANGES.txt')) as f:
CHANGES = f.read() CHANGES = f.read()

39
setup_mongo_admin.js Normal file
View File

@@ -0,0 +1,39 @@
admin = db.getSiblingDB('admin');
admin.createUser(
{
user: "admin",
pwd: "HenryPump@1903",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
}
);
poc = db.getSiblingDB('poc');
poc.createUser({
user: "poc_www",
pwd: "HenryPump1903",
roles: [ { role: "readWrite", db: "poc" } ]
});
poc = db.getSiblingDB('poc');
poc.createUser({
user: "poc_java",
pwd: "HenryPump@1903",
roles: [ { role: "readWrite", db: "poc" } ]
});
db.addUser({
"user": "patrickjmcd",
"pwd": "",
"roles": ["userAdminAnyDatabase"]
});
db.addUser({
user: "poc_www",
pwd: "HenryPump1903",
roles: ["readWrite"]
});
db.addUser({
user: "poc_java",
pwd: "HenryPump@1903",
roles: ["readWrite"]
});

View File

@@ -4,7 +4,7 @@ Documentation=http://supervisord.org
After=network.target After=network.target
[Service] [Service]
ExecStart=/usr/local/bin/supervisord -n -c /root/POC-Java-www/pocwww/supervisor.conf ExecStart=/usr/local/bin/supervisord -n -c /root/POC-Java-www/supervisor.conf
ExecStop=/usr/local/bin/supervisorctl $OPTIONS shutdown ExecStop=/usr/local/bin/supervisorctl $OPTIONS shutdown
ExecReload=/usr/local/bin/supervisorctl $OPTIONS reload ExecReload=/usr/local/bin/supervisorctl $OPTIONS reload
KillMode=process KillMode=process