improve worker - timeout and start after

This commit is contained in:
Geno 2020-11-14 10:22:25 +01:00
parent 84277b9fcb
commit 1853850a40
3 changed files with 18 additions and 2 deletions

View File

@ -3,10 +3,13 @@ osp_git_root: 'https://gitlab.com/Deamos/flask-nginx-rtmp-manager.git'
osp_git_commit: '0.7.9' osp_git_commit: '0.7.9'
osp_worker_start_port: 5000 osp_worker_start_port: 5000
osp_worker_count: "{{ ansible_processor_nproc }}" osp_worker_count: "{{ ansible_processor_nproc }}"
osp_worker_timeout: 30
# should not be edited
osp_worker_worker: 1
osp_http_user: "http" osp_http_user: "http"
osp_http_group: "http" osp_http_group: "http"
osp_http_path: "/srv/http" osp_http_path: "/var/www"
osp_db_host: localhost osp_db_host: localhost
osp_db_name: osp osp_db_name: osp

View File

@ -155,7 +155,16 @@
dest: "/opt/osp/conf/config.py" dest: "/opt/osp/conf/config.py"
state: link state: link
- name: Create logging directory
file:
path: /opt/osp
owner: "{{ osp_http_user }}"
group: "{{ osp_http_group }}"
recurse: yes
- name: Init Database - name: Init Database
become: yes
become_user: http
command: python3 manage.py db init command: python3 manage.py db init
args: args:
chdir: /opt/osp/ chdir: /opt/osp/

View File

@ -3,13 +3,17 @@ Description=Gunicorn instance to serve OSP Workers on port %i
After=network.target ejabberd.service redis.service After=network.target ejabberd.service redis.service
PartOf=osp.target PartOf=osp.target
{% if osp_db_type == "postgresql" %}
After=postgresql.service
{% endif %}
[Service] [Service]
User=http User=http
Group=http Group=http
WorkingDirectory=/opt/osp WorkingDirectory=/opt/osp
Environment="VIRTUAL_ENV=/opt/osp-venv" Environment="VIRTUAL_ENV=/opt/osp-venv"
Environment="PATH=/opt/osp-venv/bin:/usr/local/bin:/usr/bin:/bin" Environment="PATH=/opt/osp-venv/bin:/usr/local/bin:/usr/bin:/bin"
ExecStart=/opt/osp-venv/bin/gunicorn app:app -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 --bind 0.0.0.0:%i --reload --access-logfile /var/log/osp/access.log --error-logfile /var/log/osp/error.log ExecStart=/opt/osp-venv/bin/gunicorn app:app -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w {{ osp_worker_worker }} --bind 0.0.0.0:%i --timeout {{ osp_worker_timeout }} --reload --access-logfile /var/log/osp/access.log --error-logfile /var/log/osp/error.log
Restart=on-failure Restart=on-failure
RestartSec=5m RestartSec=5m