From b9ca47574d43858517a4a76b2e20978053b034fa Mon Sep 17 00:00:00 2001 From: Dorian Pula Date: Fri, 21 Nov 2014 23:09:42 -0500 Subject: [PATCH] Setup working configuration and setup for supervisord. Need to fix up deployment itself. --- config/supervisor/supervisor.conf | 58 +++++++++++++++++++++++++++++++ deployment/email_server.yaml | 3 -- deployment/supervisor.yaml | 23 +++++++++++- deployment/uwsgi.yaml | 6 +--- 4 files changed, 81 insertions(+), 9 deletions(-) diff --git a/config/supervisor/supervisor.conf b/config/supervisor/supervisor.conf index e69de29..af13ab9 100644 --- a/config/supervisor/supervisor.conf +++ b/config/supervisor/supervisor.conf @@ -0,0 +1,58 @@ +; Rookeries supervisor config file. +; +; For more information on the config file, please see: +; http://supervisord.org/configuration.html +; +; Notes: +; - Shell expansion ("~" or "$HOME") is not supported. Environment +; variables can be expanded using this syntax: "%(ENV_HOME)s". +; - Comments must have a leading space: "a=b ;comment" not "a=b;comment". + +[unix_http_server] +file=/tmp/supervisor.sock ; (the path to the socket file) +;chmod=0700 ; socket file mode (default 0700) +;chown=nobody:nogroup ; socket file uid:gid owner +;username=user ; (default is no username (open server)) +;password=123 ; (default is no password (open server)) + +;[inet_http_server] ; inet (TCP) server disabled by default +;port=127.0.0.1:9001 ; (ip_address:port specifier, *:port for all iface) +;username=user ; (default is no username (open server)) +;password=123 ; (default is no password (open server)) + +[supervisord] +logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log) +logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB) +logfile_backups=10 ; (num of main logfile rotation backups;default 10) +loglevel=info ; (log level;default info; others: debug,warn,trace) +pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid) +nodaemon=false ; (start in foreground if true;default false) +minfds=1024 ; (min. avail startup file descriptors;default 1024) +minprocs=200 ; (min. avail process descriptors;default 200) +;umask=022 ; (process file creation umask;default 022) +;user=chrism ; (default is current user, required if root) +;identifier=supervisor ; (supervisord identifier, default is 'supervisor') +;directory=/tmp ; (default is not to cd during start) +;nocleanup=true ; (don't clean up tempfiles at start;default false) +;childlogdir=/tmp ; ('AUTO' child log dir, default $TEMP) +;environment=KEY="value" ; (key value pairs to add to environment) +;strip_ansi=false ; (strip ansi escape codes in logs; def. false) + +; the below section must remain in the config file for RPC +; (supervisorctl/web interface) to work, additional interfaces may be +; added by defining them in separate rpcinterface: sections +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +[supervisorctl] +serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket + +; Mailsink configuration +[program:mailsink] +command=/srv/www/mail_server/bin/mailsinkd -w 8025 -s 25 +stopsignal=TERM + +; UWSGI for Rookeries +[program:rookeries_uwsgi] +command=/srv/www/uwsgi/bin/uwsgi --ini /srv/www/config/uwsgi/rookeries-uwsgi.ini +stopsignal=TERM diff --git a/deployment/email_server.yaml b/deployment/email_server.yaml index df4b30b..44c4e2e 100644 --- a/deployment/email_server.yaml +++ b/deployment/email_server.yaml @@ -7,6 +7,3 @@ - name: PIP install mailsink test server into target virtualenv pip: name=mailsink virtualenv={{ email_server_venv }} version=0.0.2 - -# - name: Launches the fake SMTP email daemon -# command: "{{ email_server_venv }}/bin/mailsinkd -w {{ email_web_server_port }} -s {{ email_server_port }}" diff --git a/deployment/supervisor.yaml b/deployment/supervisor.yaml index a94d4ef..f1f99f7 100644 --- a/deployment/supervisor.yaml +++ b/deployment/supervisor.yaml @@ -1,5 +1,6 @@ --- - hosts: all + sudo: yes vars: web_server_home: /srv/www web_server_group: www-data @@ -17,4 +18,24 @@ - name: Upload rookeries supervisor configuration to web server home copy: src=../config/supervisor/supervisor.conf dest={{ supervisor_config }} - # TODO Control supervisor with supervisorctl + ansible - http://docs.ansible.com/supervisorctl_module.html + - name: Link supervisor binary into /usr/local/bin + file: src={{ supervisor_venv }}/bin/{{ item }} dest=/usr/local/bin/{{ item }} state=link + with_items: + - supervisord + - supervisorctl + + - name: Check if supervisord is running + shell: pgrep supervisor + ignore_errors: on + changed_when: off + register: supervisor_running + + - name: Running supervisord + shell: "{{ supervisor_venv }}/bin/supervisord -c {{ supervisor_config }}/supervisor.conf" + when: supervisor_running|failed + + - name: Start up the mailsink program + supervisorctl: name=mailsink state=restarted config={{ supervisor_config }}/supervisor.conf + + - name: Start up the uwsgi program + supervisorctl: name=uwsgi state=restarted config={{ supervisor_config }}/supervisor.conf diff --git a/deployment/uwsgi.yaml b/deployment/uwsgi.yaml index 07aa3ab..497862f 100644 --- a/deployment/uwsgi.yaml +++ b/deployment/uwsgi.yaml @@ -1,5 +1,6 @@ --- - hosts: all + sudo: yes vars: web_server_home: /srv/www web_server_group: www-data @@ -17,8 +18,3 @@ - name: Upload rookeries UWSGI configuration to web server home copy: src=../config/uwsgi/{{ rookeries_uwsgi_ini }} dest={{ uwsgi_config }} - - # TODO Clean up configuration placement - -# - name: Launches the UWSGI daemon -# command: "{{ uwsgi_venv }}/bin/uwsgi --ini {{ web_server_home }}/{{ rookeries_uwsgi_ini }}"