Generalize UWSGI specific setup.
This commit is contained in:
parent
667761d299
commit
26a93b9558
42
README.md
42
README.md
|
@ -11,7 +11,6 @@ Requirements
|
|||
------------
|
||||
|
||||
- aptitude or python-apt (required by apt tasks)
|
||||
- python > 2.5 (required by ini_file tasks)
|
||||
|
||||
This role is designed to work against a modern Ubuntu system. (Tested on Ubuntu 13.10 and 14.04) It should
|
||||
theoretically work on older versions of Ubuntu or Debian based systems.
|
||||
|
@ -20,16 +19,15 @@ Example Playbook
|
|||
----------------
|
||||
|
||||
The simplest way to include the role in your playbook is to copy the below configuration. Remember to modify the
|
||||
app_name, app_nginx_hostname and app_uwsgi_executable parameters especially.
|
||||
app_name, app_nginx_hostname and app_service_command parameters especially.
|
||||
|
||||
- hosts: servers
|
||||
sudo: yes
|
||||
roles:
|
||||
- { role: nginx-uwsgi-supervisor,
|
||||
- { role: nginx-supervisor,
|
||||
app_name: app,
|
||||
app_nginx_hostname: app.domain.net,
|
||||
app_uwsgi_port: 8080,
|
||||
app_uwsgi_executable: "app.build:make_wsgi_app()" }
|
||||
app_service_command: app_executable --port 9000 }
|
||||
|
||||
The role itself is very configurable. For exaple, if you prefer the location of the web application to refer to the
|
||||
domain name rather than the default root path, then simply override the app_root_path variable with something like:
|
||||
|
@ -63,17 +61,13 @@ into sections and described below:
|
|||
- The path to the static elements of the site (templates, CSS, images, etc.)
|
||||
- Default: app_root_path/app_name/static/
|
||||
|
||||
### UWSGI
|
||||
### App Specific
|
||||
|
||||
- app_uwsgi_port:
|
||||
- The port number that the WSGI runs on and accepts requests forwarded from NGINX.
|
||||
- Default: 8001
|
||||
- app_uwsgi_executable:
|
||||
- The method executed by UWSGI to create a WSGI running app. Usually a WSGI factory method or module in the app.
|
||||
- Default: app:make_wsgi_app()
|
||||
- app_uwsgi_envs:
|
||||
- (Optional) A dictionary of environment variables to pass into an app.
|
||||
- Default: empty dictionary
|
||||
- app_service_command:
|
||||
- The full command to execute to run the application
|
||||
- app_service_stop_signal:
|
||||
- The signal used to gracefully stop the application.
|
||||
- Default: QUIT (as in SIGQUIT)
|
||||
|
||||
### General Web
|
||||
|
||||
|
@ -111,25 +105,15 @@ work with your setup:
|
|||
- web_user:
|
||||
- The non-root user who is allowed to control web + app servers on the target machine.
|
||||
- Default: current user
|
||||
- virtualenv_root_path:
|
||||
- The common root directory of Python virtual environments associated with running the
|
||||
UWSGI app + server.
|
||||
- Default: /srv/www/virtualenvs/
|
||||
- nginx_app_conf:
|
||||
- The filename of the NGINX configuration for the app.
|
||||
- Default: app_name_uwsgi_nginx.conf
|
||||
- Default: app_name_nginx.conf
|
||||
- supervisor_app_config:
|
||||
- The filename of the supervisor configuration for the app.
|
||||
- Default: app_name_supervisor.conf
|
||||
- uwsgi_config_path:
|
||||
- The path to the UWSGI configurations.
|
||||
- Default: /srv/www/config/uwsgi
|
||||
- uwsgi_app_ini:
|
||||
- The filename of the UWSGI INI configuration for the app.
|
||||
- Default: app_name_uwsgi.ini
|
||||
- uwsgi_service_name:
|
||||
- The name of the UWSGI setup for the app according to supervisor.
|
||||
- Default: app_name_uwsgi
|
||||
- app_service_name:
|
||||
- The name of the service setup for the app according to supervisor.
|
||||
- Default: app_name
|
||||
|
||||
License
|
||||
-------
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
galaxy_info:
|
||||
author: Dorian Pula
|
||||
description: An elegant NGINX, UWSGI and supervisor Ansible role
|
||||
description: An elegant NGINX and supervisor Ansible base role
|
||||
company: Amber Penguin Software
|
||||
license: BSD
|
||||
min_ansible_version: 1.6
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
sudo: yes
|
||||
|
||||
- name: configure nginx
|
||||
template: src=nginx/app_uwsgi_nginx.conf dest=/etc/nginx/sites-available/{{ nginx_app_config }}
|
||||
template: src=app_nginx.conf dest=/etc/nginx/sites-available/{{ nginx_app_config }}
|
||||
sudo: yes
|
||||
|
||||
- name: link to enable nginx configuration
|
||||
|
|
|
@ -20,6 +20,6 @@
|
|||
sudo: yes
|
||||
|
||||
- name: upload supervisor configuration to web server home
|
||||
template: src=supervisor/app_supervisor.conf dest=/etc/supervisor/conf.d/{{ supervisor_app_config }}
|
||||
template: src=app_supervisor.conf dest=/etc/supervisor/conf.d/{{ supervisor_app_config }}
|
||||
sudo: yes
|
||||
notify: start supervisord
|
||||
|
|
|
@ -9,10 +9,9 @@ server {
|
|||
}
|
||||
|
||||
location / {
|
||||
try_files $uri @yourapplication;
|
||||
try_files $uri @{{app_name}}_app;
|
||||
}
|
||||
location @yourapplication {
|
||||
include uwsgi_params;
|
||||
uwsgi_pass 127.0.0.1:{{ app_uwsgi_port }};
|
||||
location @{{app_name}}_app {
|
||||
# TODO: Find way to stitch together templates.
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
; UWSGI for {{ app_name }}
|
||||
[program:{{ uwsgi_app_service_name }}]
|
||||
[program:{{ app_service_name }}]
|
||||
user={{ web_server_group }}
|
||||
command={{ uwsgi_venv }}/bin/uwsgi --ini {{ uwsgi_config_path }}/{{ uwsgi_app_ini }}
|
||||
stopsignal=QUIT
|
||||
command={{ app_service_command }}
|
||||
stopsignal={{ app_service_stop_signal }}
|
||||
stdout_logfile = {{ web_root_path }}/logs/supervisor/{{ app_name }}-application.log
|
||||
stdout_logfile_backups = 5
|
||||
stderr_logfile = {{ web_root_path }}/logs/supervisor/{{ app_name }}-error.log
|
|
@ -5,7 +5,12 @@
|
|||
web_user: "{{ ansible_env.SUDO_USER }}"
|
||||
|
||||
# NGINX
|
||||
nginx_app_config: "{{ app_name }}_uwsgi_nginx.conf"
|
||||
nginx_app_config: "{{ app_name }}_nginx.conf"
|
||||
|
||||
# Supervisor
|
||||
supervisor_app_config: "{{ app_name }}_supervisor.conf"
|
||||
|
||||
# App specific configuration
|
||||
app_service_name: "{{ app_name }}"
|
||||
app_service_command: "echo {{ app_name }}"
|
||||
app_service_stop_signal: QUIT
|
||||
|
|
Loading…
Reference in New Issue