Compare commits
11 Commits
optimize-t
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51ec43b85d | ||
|
|
13835dcfa4 | ||
|
|
b500baeaf1 | ||
|
|
32b7a82886 | ||
|
|
0e58c84c6a | ||
|
|
d5ff30356a | ||
|
|
351e0674de | ||
|
|
2be84b694b | ||
|
|
1cc1933df4 | ||
|
|
eeaef59d89 | ||
|
|
58a84756ce |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -3,3 +3,7 @@ env/*
|
||||
pocwww.egg*
|
||||
pocwww/__pycache__/*
|
||||
pocwww.egg-info/*
|
||||
|
||||
*.pyc
|
||||
.idea/*
|
||||
.idea/vcs.xml
|
||||
|
||||
22
Dockerfile
Normal file
22
Dockerfile
Normal 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
32
README.md
Normal 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
|
||||
```
|
||||
12
README.txt
12
README.txt
@@ -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`
|
||||
@@ -19,7 +19,6 @@ pyramid.includes =
|
||||
# debugtoolbar.hosts = 127.0.0.1 ::1
|
||||
|
||||
mongo_uri = mongodb://poc_www:HenryPump1903@localhost:27017/poc
|
||||
# mongo_uri = mongodb://10.20.155.202:27017/poc
|
||||
|
||||
|
||||
###
|
||||
|
||||
30
docker-compose.yml
Normal file
30
docker-compose.yml
Normal 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
|
||||
@@ -179,7 +179,6 @@ def main(global_config, **settings):
|
||||
config.add_route('users_register', '/register', factory='pocwww.security.UserLoginFactory')
|
||||
config.add_route("users_json", "/json/users", factory='pocwww.security.UserLoginFactory')
|
||||
|
||||
|
||||
# POC Interface
|
||||
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
|
||||
@@ -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_setpoints', '/setpoints', factory='pocwww.security.UserLoginFactory')
|
||||
|
||||
|
||||
|
||||
|
||||
config.scan()
|
||||
return config.make_wsgi_app()
|
||||
|
||||
@@ -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}
|
||||
@@ -24,10 +24,10 @@ def my_view(request):
|
||||
for t in latesttag_agg:
|
||||
latest_tag_values.append(t)
|
||||
|
||||
latest_card = []
|
||||
latest_card = None
|
||||
try:
|
||||
latest_card = list(request.db['cards'].find().sort("timestamp", -1).limit(1))[0]
|
||||
except IndexError:
|
||||
latest_card = []
|
||||
latest_card = None
|
||||
|
||||
return {'project': 'POC Web Interface', 'navgroup': 'dashboard', 'tag_values': latest_tag_values, 'card': latest_card}
|
||||
|
||||
@@ -10,6 +10,12 @@ def get_poc_address(request):
|
||||
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")
|
||||
def json_updateconfig(request):
|
||||
conv_to_float = [
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<h2 class="allcaps">Latest Card</h2>
|
||||
{% if card is defined %}
|
||||
{% if card is mapping %}
|
||||
<h3>{{card.timestamp | datetime('long')}}</h1>
|
||||
<canvas id="surfacecard" height="140"></canvas>
|
||||
<canvas id="downholecard" height="140"></canvas>
|
||||
|
||||
@@ -10,7 +10,7 @@ pyramid.debug_authorization = false
|
||||
pyramid.debug_notfound = false
|
||||
pyramid.debug_routematch = false
|
||||
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 ----------
|
||||
@@ -28,7 +28,7 @@ pipeline =
|
||||
|
||||
[server:main]
|
||||
use = egg:waitress#main
|
||||
host = 127.0.0.1
|
||||
host = 0.0.0.0
|
||||
port = %(http_port)s
|
||||
|
||||
|
||||
|
||||
2
setup.py
2
setup.py
@@ -3,7 +3,7 @@ import os
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
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()
|
||||
with open(os.path.join(here, 'CHANGES.txt')) as f:
|
||||
CHANGES = f.read()
|
||||
|
||||
39
setup_mongo_admin.js
Normal file
39
setup_mongo_admin.js
Normal 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"]
|
||||
});
|
||||
@@ -4,7 +4,7 @@ Documentation=http://supervisord.org
|
||||
After=network.target
|
||||
|
||||
[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
|
||||
ExecReload=/usr/local/bin/supervisorctl $OPTIONS reload
|
||||
KillMode=process
|
||||
|
||||
Reference in New Issue
Block a user