From: Lorin Hochstein Date: Sat, 24 Dec 2016 06:09:49 +0000 (-0800) Subject: Fix supervisor issues X-Git-Url: https://git.halfball.org/?a=commitdiff_plain;h=088ecc8e90c72c613cfdf68988f41b53009ddb87;p=ansiblebook.git Fix supervisor issues --- diff --git a/ch06/playbooks/mezzanine.yml b/ch06/playbooks/mezzanine.yml index 1a02cbf..0f40b89 100644 --- a/ch06/playbooks/mezzanine.yml +++ b/ch06/playbooks/mezzanine.yml @@ -3,7 +3,8 @@ hosts: web vars: user: "{{ ansible_user }}" - proj_name: mezzanine_example + proj_app: mezzanine_example + proj_name: "{{ proj_app }}" venv_home: "{{ ansible_env.HOME }}/.virtualenvs" venv_path: "{{ venv_home }}/{{ proj_name }}" proj_dirname: project @@ -28,6 +29,7 @@ database_host: localhost database_port: 5432 gunicorn_proc_name: mezzanine + num_workers: "multiprocessing.cpu_count() * 2 + 1" vars_files: - secrets.yml tasks: @@ -147,22 +149,21 @@ environment: PATH: "{{ venv_path }}/bin" PROJECT_DIR: "{{ proj_path }}" - PROJECT_APP: "{{ proj_name }}" + PROJECT_APP: "{{ proj_app }}" WEBSITE_DOMAIN: "{{ live_hostname }}" - name: set the admin password script: scripts/setadmin.py environment: PATH: "{{ venv_path }}/bin" PROJECT_DIR: "{{ proj_path }}" - PROJECT_APP: "{{ proj_name }}" + PROJECT_APP: "{{ proj_app }}" ADMIN_PASSWORD: "{{ admin_pass }}" handlers: - name: restart supervisor - supervisorctl: name=gunicorn_mezzanine state=restarted + supervisorctl: "name=gunicorn_{{ proj_name }} state=restarted" become: True - name: restart nginx service: name=nginx state=restarted become: True - name: restart postgres service: name=postgresql state=restarted - diff --git a/ch06/playbooks/templates/gunicorn.conf.py.j2 b/ch06/playbooks/templates/gunicorn.conf.py.j2 index 7a3d665..0da0577 100644 --- a/ch06/playbooks/templates/gunicorn.conf.py.j2 +++ b/ch06/playbooks/templates/gunicorn.conf.py.j2 @@ -1,7 +1,8 @@ from __future__ import unicode_literals import multiprocessing -bind = "127.0.0.1:{{ gunicorn_port }}" -workers = multiprocessing.cpu_count() * 2 + 1 +bind = "unix:{{ proj_path }}/gunicorn.sock" +workers = {{ num_workers }} +errorlog = "/home/{{ user }}/logs/{{ proj_name }}_error.log" loglevel = "error" proc_name = "{{ proj_name }}" diff --git a/ch06/playbooks/templates/supervisor.conf.j2 b/ch06/playbooks/templates/supervisor.conf.j2 index 44574f6..7a7a4bb 100644 --- a/ch06/playbooks/templates/supervisor.conf.j2 +++ b/ch06/playbooks/templates/supervisor.conf.j2 @@ -1,11 +1,9 @@ -[group: {{proj_name}}] -programs=gunicorn_{{ proj_name }} - [program:gunicorn_{{ proj_name }}] -command={{ venv_path }}/bin/gunicorn_django -c gunicorn.conf.py -p gunicorn.pid +command={{ venv_path }}/bin/gunicorn -c gunicorn.conf.py -p gunicorn.pid {{ proj_app }}.wsgi:application directory={{ proj_path }} user={{ user }} autostart=true +stdout_logfile = /home/{{ user }}/logs/{{ proj_name }}_supervisor autorestart=true redirect_stderr=true environment=LANG="{{ locale }}",LC_ALL="{{ locale }}",LC_LANG="{{ locale }}"