Implement uWSGI for sahara-api
As part of the Pike goals we are moving api services to run as WSGI apps. sahara-api service is set up as a wsgi app, and this patch moves it over. Since this is just a drop in replacement for the existing eventlet service, operators an deployers should notice no difference. Change-Id: Ie4826358d5ee1686ad9ea7fa9eb0441acff565f2 Implements: blueprint goal-deploy-api-in-wsgi
This commit is contained in:
parent
fdc19eb559
commit
55f437b447
@ -161,6 +161,7 @@ sahara_pip_packages:
|
||||
- python-keystoneclient
|
||||
- sahara
|
||||
- warlock
|
||||
- uwsgi
|
||||
|
||||
sahara_engine_init_overrides: {}
|
||||
sahara_api_init_overrides: {}
|
||||
@ -171,11 +172,24 @@ sahara_services:
|
||||
group: sahara_api
|
||||
service_name: sahara-api
|
||||
init_config_overrides: "{{ sahara_api_init_overrides }}"
|
||||
wsgi_overrides: "{{ sahara_api_uwsgi_ini_overrides }}"
|
||||
wsgi_app: True
|
||||
log_string: "--logto "
|
||||
wsgi_name: sahara-wsgi-api
|
||||
uwsgi_port: "{{ sahara_api_service_port }}"
|
||||
uwsgi_bind_address: "{{ sahara_api_bind_address }}"
|
||||
program_override: "{{ sahara_bin }}/uwsgi --ini /etc/uwsgi/sahara-api.ini"
|
||||
sahara-engine:
|
||||
group: sahara_engine
|
||||
service_name: sahara-engine
|
||||
init_config_overrides: "{{ sahara_engine_init_overrides }}"
|
||||
|
||||
## Sahara uWSGI settings
|
||||
sahara_wsgi_processes_max: 16
|
||||
sahara_wsgi_processes: "{{ [[ansible_processor_vcpus|default(1), 1] | max * 2, sahara_wsgi_processes_max] | min }}"
|
||||
sahara_wsgi_threads: 1
|
||||
sahara_wsgi_buffer_size: 65535
|
||||
|
||||
# This variable is used by the repo_build process to determine
|
||||
# which host group to check for members of before building the
|
||||
# pip packages required by this role. The value is picked up
|
||||
@ -187,3 +201,4 @@ sahara_api_paste_ini_overrides: {}
|
||||
sahara_conf_overrides: {}
|
||||
sahara_rootwrap_conf_overrides: {}
|
||||
sahara_policy_overrides: {}
|
||||
sahara_api_uwsgi_ini_overrides: {}
|
||||
|
15
releasenotes/notes/sahara_uwsgi-41e7e0a91a3f8c33.yaml
Normal file
15
releasenotes/notes/sahara_uwsgi-41e7e0a91a3f8c33.yaml
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
features:
|
||||
- The ``sahara-api`` service has moved to run as a
|
||||
uWSGI application. You can set the max number of
|
||||
WSGI processes, the number of processes, threads,
|
||||
and buffer size utilizing the
|
||||
``sahara_wsgi_processes_max``,
|
||||
``sahara_wsgi_processes``, ``sahara_wsgi_threads``,
|
||||
and ``sahara_wsgi_buffer_size``.
|
||||
Additionally, you can override any settings in the
|
||||
uWSGI ini configuration file using the
|
||||
``sahara_api_uwsgi_ini_overrides`` setting.
|
||||
The uWSGI application will listen on the address
|
||||
specified by ``sahara_uwsgi_bind_address`` which
|
||||
defaults to ``0.0.0.0``.
|
@ -35,6 +35,10 @@
|
||||
tags:
|
||||
- sahara-config
|
||||
|
||||
- include: sahara_uwsgi.yml
|
||||
tags:
|
||||
- sahara-config
|
||||
|
||||
- include: sahara_init_common.yml
|
||||
tags:
|
||||
- sahara-config
|
||||
|
32
tasks/sahara_uwsgi.yml
Normal file
32
tasks/sahara_uwsgi.yml
Normal file
@ -0,0 +1,32 @@
|
||||
---
|
||||
# Copyright 2017, Rackspace US, Inc.
|
||||
#
|
||||
# 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.
|
||||
|
||||
- name: Ensure uWSGI directory exists
|
||||
file:
|
||||
path: "/etc/uwsgi/"
|
||||
state: directory
|
||||
mode: "0711"
|
||||
|
||||
- name: Apply uWSGI configuration
|
||||
config_template:
|
||||
src: "sahara-uwsgi.ini.j2"
|
||||
dest: "/etc/uwsgi/{{ item.value.service_name }}.ini"
|
||||
mode: "0744"
|
||||
config_overrides: "{{ item.value.wsgi_overrides }}"
|
||||
config_type: ini
|
||||
with_dict: "{{ sahara_services }}"
|
||||
when: item.value.wsgi_app | default(False)
|
||||
notify:
|
||||
- Restart sahara services
|
@ -10,10 +10,10 @@ Type=simple
|
||||
User={{ sahara_system_user_name }}
|
||||
Group={{ sahara_system_group_name }}
|
||||
|
||||
{% if program_override is defined %}
|
||||
ExecStart={{ program_override }} {{ program_config_options|default('') }} --log-file=/var/log/sahara/{{ item.value.service_name }}.log
|
||||
{% if item.value.program_override is defined %}
|
||||
ExecStart={{ item.value.program_override }} {{ item.value.program_config_options|default('') }} {{ item.value.log_string | default('--log-file=') }}/var/log/sahara/{{ item.value.service_name }}.log
|
||||
{% else %}
|
||||
ExecStart={{ sahara_bin }}/{{ item.value.service_name }} {{ program_config_options|default('') }} --log-file=/var/log/sahara/{{ item.value.service_name }}.log
|
||||
ExecStart={{ sahara_bin }}/{{ item.value.service_name }} {{ item.value.program_config_options|default('') }} --log-file=/var/log/sahara/{{ item.value.service_name }}.log
|
||||
{% endif %}
|
||||
|
||||
# Give a reasonable amount of time for the server to start up/shut down
|
||||
|
19
templates/sahara-uwsgi.ini.j2
Normal file
19
templates/sahara-uwsgi.ini.j2
Normal file
@ -0,0 +1,19 @@
|
||||
[uwsgi]
|
||||
uid = {{ sahara_system_user_name }}
|
||||
gid = {{ sahara_system_group_name }}
|
||||
|
||||
virtualenv = /openstack/venvs/sahara-{{ sahara_venv_tag }}
|
||||
wsgi-file = {{ sahara_bin }}/{{ item.value.wsgi_name }}
|
||||
http-socket = {{ item.value.uwsgi_bind_address }}:{{ item.value.uwsgi_port }}
|
||||
|
||||
master = true
|
||||
enable-threads = true
|
||||
processes = {{ sahara_wsgi_processes }}
|
||||
threads = {{ sahara_wsgi_threads }}
|
||||
exit-on-reload = true
|
||||
die-on-term = true
|
||||
lazy-apps = true
|
||||
add-header = Connection: close
|
||||
buffer-size = {{ sahara_wsgi_buffer_size }}
|
||||
thunder-lock = true
|
||||
logfile-chmod = 644
|
@ -16,3 +16,4 @@ sahara_distro_packages:
|
||||
- rpcbind
|
||||
- git
|
||||
- which
|
||||
- libxml2-devel
|
||||
|
@ -20,3 +20,4 @@ sahara_distro_packages:
|
||||
- rpcbind
|
||||
- rsync
|
||||
- git
|
||||
- libxml2-dev
|
||||
|
Loading…
Reference in New Issue
Block a user