Skip to content

Commit

Permalink
merge: #210 from dev
Browse files Browse the repository at this point in the history
  • Loading branch information
alycejenni authored Nov 1, 2024
2 parents 915afa5 + d0aac4f commit 64c0a34
Show file tree
Hide file tree
Showing 17 changed files with 54 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ dist/
api/phenome10k.egg-info/

docker/local.env

logs/
5 changes: 3 additions & 2 deletions ansible/group_vars/all/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ flower_broker_api: http://{{ p10k_db_user }}:{{ p10k_db_password|urlencode() }}@
# p10k: flask
cache_redis_url: redis://{{ redis_host }}:6379/1
flask_secret_key: G}<Ci&XWqSqA/mF7ZCWI7JJ.:QuuZF
gunicorn_binary: '{{ venv_bin }}/gunicorn'
gunicorn_port: 8000
uwsgi_binary: "{{ venv_bin }}/uwsgi"
uwsgi_ini: "{{ p10k_home }}/uswgi.ini"
uwsgi_port: 8000
p10k_admin_email: [email protected]
p10k_admin_password: pass
password_salt: 7mrUh6kF*&PEh2gUTmHc
Expand Down
2 changes: 1 addition & 1 deletion ansible/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
- monit/monit
vars:
monit_services:
- gunicorn
- uwsgi
- systems
- 50gb-root-partition

Expand Down
8 changes: 4 additions & 4 deletions ansible/roles/monit/monit/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ monit_eventqueue:
# Active - try and restart services
monit_monitoring_mode: active
monit_services_conf:
gunicorn:
uwsgi:
check_type: process
check_id: gunicorn
check_id: uwsgi
id_type: matching
start: /bin/systemctl restart gunicorn
stop: /bin/systemctl stop gunicorn
start: /bin/systemctl restart uwsgi
stop: /bin/systemctl stop uwsgi
group: web
tests:
- condition: cpu > 60% for 20 cycles
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/nginx/templates/phenome10k.org.conf.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
upstream phenome10k {
{% for server in app_servers %} server {{ server }}:{{ gunicorn_port }};{% endfor %}
{% for server in app_servers %} server {{ server }}:{{ uwsgi_port }};{% endfor %}
}

server {
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/nginx/templates/phenome10k.org.ssl.conf.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
upstream phenome10k {
{% for server in app_servers %} server {{ server }}:{{ gunicorn_port }};{% endfor %}
{% for server in app_servers %} server {{ server }}:{{ uwsgi_port }};{% endfor %}
}

server {
Expand Down
4 changes: 2 additions & 2 deletions ansible/roles/phenome-10k/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
become: true
become_user: phenome10k

- name: restart gunicorn
- name: restart uwsgi
service:
name: gunicorn
name: uwsgi
state: restarted
become: true

Expand Down
21 changes: 15 additions & 6 deletions ansible/roles/phenome-10k/tasks/app-flask.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,26 @@
become_user: phenome10k
run_once: true

- name: Create the gunicorn service
- name: Copy uwsgi.ini config
template:
src: gunicorn.service.j2
dest: /etc/systemd/system/gunicorn.service
src: uwsgi.ini.j2
dest: '{{ uwsgi_ini }}'
become: true
become_user: phenome10k
notify:
- restart uwsgi

- name: Create the uwsgi service
template:
src: uwsgi.service.j2
dest: /etc/systemd/system/uwsgi.service
become: true
notify:
- restart gunicorn
- restart uwsgi

- name: Enable gunicorn service
- name: Enable uwsgi service
systemd:
name: gunicorn.service
name: uwsgi.service
state: started
enabled: y
become: true
4 changes: 2 additions & 2 deletions ansible/roles/phenome-10k/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
when: not skip_git_checkout
notify:
- rebuild front end
- restart gunicorn
- restart uwsgi
- restart node
tags:
- flask
Expand Down Expand Up @@ -55,7 +55,7 @@
become: true
become_user: phenome10k
notify:
- restart gunicorn
- restart uwsgi

- name: Create log directory
file:
Expand Down
14 changes: 14 additions & 0 deletions ansible/roles/phenome-10k/templates/uwsgi.ini.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[uwsgi]
http = 0.0.0.0:{{ uwsgi_port }}
wsgi-file = api/wsgi.py
callable = app
wsgi-disable-file-wrapper = true
master = true
processes = 3
threads = 3
buffer-size = 65535
stats = 127.0.0.1:9191
log-5xx = true

req-logger = file:/var/log/phenome10k/u_access.log
logger = file:/var/log/phenome10k/u_error.log
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Description=phenome10k service

[Service]
Type=simple
ExecStart={{ gunicorn_binary }} --error-logfile /var/log/phenome10k/error.log --access-logfile /var/log/phenome10k/access.log -b 0.0.0.0:{{ gunicorn_port }} -w 9 --timeout 120 api.wsgi:app
ExecStart={{ uwsgi_binary }} --ini {{ uwsgi_ini }}
Restart=on-abort
WorkingDirectory={{ p10k_src_dir }}
User={{ p10k_linux_user }}
Expand Down
2 changes: 1 addition & 1 deletion api/phenome10k/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Config(object):
MAIL_PORT = os.environ.get('MAIL_PORT', 25)
MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
ADMIN_EMAIL = os.environ.get('ADMIN_EMAIL') or '[email protected]'
ADMIN_EMAIL = os.environ.get('ADMIN_EMAIL') or '[email protected]'
LOG_FILE = os.environ.get('LOG_FILE') or 'logs/phenome10k.log'
LOG_LEVEL = os.environ.get('LOG_LEVEL', 'WARNING')
SERVER_NAME = os.environ.get('SERVER_NAME') or None
Expand Down
1 change: 1 addition & 0 deletions api/phenome10k/routes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def init_routes(app):
query.bp,
]

app.url_map.strict_slashes = False
app.url_map.converters['scan'] = ScanConverter
app.url_map.converters['publication'] = PublicationConverter
app.url_map.converters['file'] = FileConverter
Expand Down
2 changes: 2 additions & 0 deletions api/phenome10k/routes/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ def search(self, **kwargs):
for c in self._columns.values():
try:
v = c.type.python_type(r.q)
if type(v) is bool:
continue
or_filters.append(c == v)
except:
continue
Expand Down
2 changes: 1 addition & 1 deletion api/phenome10k/routes/publications.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def manage(page=1):
return render_vue(data, title='Manage Publications')


@bp.route('/<publication:pub_object>/')
@bp.route('/<publication:pub_object>')
def view(pub_object):
if not pub_object.published and not (
current_user.is_authenticated and current_user.can_edit(pub_object)
Expand Down
2 changes: 1 addition & 1 deletion api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ requires-python = ">=3.8"
license = { text = "GPL-3.0-or-later" }
authors = [
{ name = "Paul Kiddle" },
{ name = "Ginger Butcher", email = "[email protected]" }
{ name = "Ginger Burns", email = "[email protected]" }
]
keywords = []
classifiers = [
Expand Down
4 changes: 2 additions & 2 deletions api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ Flask==2.0.3
flask-caching==2.3.0
flask-hcaptcha==0.6.0
Flask-Mail==0.9.1
Flask-Marshmallow==0.14.0
Flask-Migrate==3.1.0
flask-security-too==5.0.1
Flask-SQLAlchemy==2.5.1
Flask-WTF==1.0.1
Flask-Marshmallow==0.14.0
flower==1.2.0
gunicorn==20.1.0
pyuwsgi==2.0.26
importlib-metadata==4.11.3
marshmallow-sqlalchemy==0.28.0
numpy==1.22.3
Expand Down

0 comments on commit 64c0a34

Please sign in to comment.