Start using uWSGI role
Move service to use uWSGI role instead of iternal task for uwsgi deployment. This aims to ease the maintenance of uWSGI and speedup metal deployments as the same uwsgi environment will be used across all services. Change-Id: I5b0bcd6a51f237fcd772368f51a406421ffb52f4
This commit is contained in:
parent
b49305b8bd
commit
f3285ed7ad
|
@ -126,9 +126,12 @@ cloudkitty_services:
|
|||
group: cloudkitty_all
|
||||
service_name: cloudkitty-api
|
||||
init_config_overrides: "{{ cloudkitty_api_init_overrides }}"
|
||||
execstarts: "{{ cloudkitty_bin }}/uwsgi --ini /etc/uwsgi/cloudkitty-api.ini"
|
||||
execreloads: "{{ cloudkitty_bin }}/uwsgi --reload /var/run/cloudkitty-api/cloudkitty-api.pid"
|
||||
start_order: 1
|
||||
wsgi_app: True
|
||||
wsgi_path: "{{ cloudkitty_bin }}/cloudkitty-api"
|
||||
uwsgi_overrides: "{{ cloudkitty_api_uwsgi_overrides }}"
|
||||
uwsgi_port: "{{ cloudkitty_service_port }}"
|
||||
uwsgi_bind_address: "{{ cloudkitty_uwsgi_bind_address }}"
|
||||
cloudkitty-processor:
|
||||
group: cloudkitty_all
|
||||
service_name: cloudkitty-processor
|
||||
|
@ -146,7 +149,6 @@ cloudkitty_pip_packages:
|
|||
- SQLAlchemy>=1.0.10
|
||||
- systemd-python
|
||||
- tooz
|
||||
- uwsgi
|
||||
|
||||
## (Qdrouterd) integration
|
||||
# TODO(ansmith): Change structure when more backends will be supported
|
||||
|
|
|
@ -43,5 +43,6 @@
|
|||
config_type: "yaml"
|
||||
notify:
|
||||
- Restart cloudkitty services
|
||||
- Restart uwsgi services
|
||||
tags:
|
||||
- cloudkitty-config
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
---
|
||||
- name: Ensure uWSGI directory exists
|
||||
file:
|
||||
path: "/etc/uwsgi/"
|
||||
state: directory
|
||||
mode: "0711"
|
||||
- name: Copy cloudkitty wsgi to apache directory
|
||||
template:
|
||||
src: cloudkitty-wsgi.py.j2
|
||||
dest: "{{ cloudkitty_bin }}/cloudkitty-wsgi.py"
|
||||
owner: "{{ cloudkitty_system_user_name }}"
|
||||
group: "{{ cloudkitty_system_user_name }}"
|
||||
mode: 0755
|
||||
- name: Apply uWSGI configuration
|
||||
config_template:
|
||||
src: cloudkitty-uwsgi.ini.j2
|
||||
dest: /etc/uwsgi/cloudkitty-api.ini
|
||||
mode: 0744
|
||||
config_overrides: "{{ cloudkitty_api_uwsgi_overrides }}"
|
||||
config_type: ini
|
||||
notify:
|
||||
- Restart cloudkitty-api
|
|
@ -96,9 +96,16 @@
|
|||
tags:
|
||||
- cloudkitty-config
|
||||
|
||||
- import_tasks: cloudkitty_wsgi.yml
|
||||
- name: Import uwsgi role
|
||||
import_role:
|
||||
name: uwsgi
|
||||
vars:
|
||||
uwsgi_services: "{{ uwsgi_cloudkitty_services }}"
|
||||
uwsgi_install_method: "source"
|
||||
tags:
|
||||
- cloudkitty-config
|
||||
- uwsgi
|
||||
|
||||
|
||||
- import_tasks: service_setup.yml
|
||||
vars:
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
# {{ ansible_managed }}
|
||||
[uwsgi]
|
||||
uid = {{ cloudkitty_system_user_name }}
|
||||
gid = {{ cloudkitty_system_group_name }}
|
||||
|
||||
virtualenv = /openstack/venvs/cloudkitty-{{ cloudkitty_venv_tag }}
|
||||
wsgi-file = {{ cloudkitty_bin }}/cloudkitty-wsgi.py
|
||||
http = :{{ cloudkitty_service_port }}
|
||||
disable-logging = true
|
||||
|
||||
master = true
|
||||
enable-threads = true
|
||||
processes = {{ cloudkitty_wsgi_processes }}
|
||||
threads = {{ cloudkitty_wsgi_threads }}
|
||||
exit-on-reload = true
|
||||
die-on-term = true
|
||||
lazy-apps = true
|
||||
add-header = Connection: close
|
||||
buffer-size = 65535
|
||||
thunder-lock = true
|
||||
|
||||
# Avoid filling up the logs with health check requests from haproxy.
|
||||
route-user-agent = ^osa-haproxy-healthcheck$ donotlog:
|
|
@ -1,29 +0,0 @@
|
|||
# -*- mode: python -*-
|
||||
#
|
||||
# Copyright 2013 New Dream Network, LLC (DreamHost)
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""Use this file for deploying the API under mod_wsgi.
|
||||
|
||||
See http://pecan.readthedocs.org/en/latest/deployment.html for details.
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
activate_this = os.path.expanduser("{{ cloudkitty_bin }}/activate_this.py")
|
||||
execfile(activate_this, dict(__file__=activate_this))
|
||||
|
||||
from cloudkitty.api import app
|
||||
|
||||
application = app.build_wsgi_app(argv=[])
|
|
@ -51,3 +51,7 @@
|
|||
src: https://opendev.org/openstack/ansible-role-python_venv_build
|
||||
scm: git
|
||||
version: master
|
||||
- name: uwsgi
|
||||
src: https://opendev.org/openstack/ansible-role-uwsgi
|
||||
scm: git
|
||||
version: master
|
||||
|
|
|
@ -23,9 +23,30 @@ filtered_cloudkitty_services: |-
|
|||
{% for key, value in cloudkitty_services.items() %}
|
||||
{% if (value['group'] in group_names) and
|
||||
(('condition' not in value) or
|
||||
('condition' in value and value['condition'])) %}
|
||||
('condition' in value and value['condition']))
|
||||
and not ('wsgi_app' in value and value['wsgi_app']) %}
|
||||
{% set _ = value.update({'service_key': key}) %}
|
||||
{% set _ = services.append(value) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{{ services | sort(attribute='start_order') }}
|
||||
|
||||
uwsgi_cloudkitty_services: |-
|
||||
{% set services = {} %}
|
||||
{% for key, value in cloudkitty_services.items() %}
|
||||
{% if (value['group'] in group_names) and
|
||||
(('condition' not in value) or ('condition' in value and value['condition']))
|
||||
and ('wsgi_app' in value and value['wsgi_app']) %}
|
||||
{% set _ = value.update(
|
||||
{
|
||||
'wsgi_venv': cloudkitty_bin,
|
||||
'uwsgi_uid': cloudkitty_system_user_name,
|
||||
'uwsgi_guid': cloudkitty_system_group_name,
|
||||
'uwsgi_processes': cloudkitty_wsgi_processes,
|
||||
'uwsgi_threads': cloudkitty_wsgi_threads
|
||||
}
|
||||
) %}
|
||||
{% set _ = services.update({key: value}) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{{ services }}
|
||||
|
|
Loading…
Reference in New Issue