From af016709f4084a2038d30b474e788b2e72216340 Mon Sep 17 00:00:00 2001 From: Stefan Midjich Date: Mon, 18 Apr 2016 21:42:29 +0200 Subject: [PATCH] example configurations. --- README.md | 8 +++++++- docs/examples/nginx/nginx.conf | 17 +++++++++++++++++ docs/examples/supervisord/captiveportal.ini | 14 ++++++++++++++ docs/examples/supervisord/rqworker.ini | 20 ++++++++++++++++++++ 4 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 docs/examples/nginx/nginx.conf create mode 100644 docs/examples/supervisord/captiveportal.ini create mode 100644 docs/examples/supervisord/rqworker.ini diff --git a/README.md b/README.md index 8c236e3..d52c265 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,9 @@ Plugins are executed when the user clicks through the captive portal form, wheth Plugins accept data from the request of the user, as of writing this is only wsgi environ data. -There is a sample plugin called logging.py. Plugins are merely rq jobs that are executed by an rq worker. As such they can only be so complex. +Sample plugins prefixed with sample\_ are a good starting point for understanding the plugins. + +Plugins can be made mandatory, or skipped by being disabled, see plugins.cfg for more configuration. # Get started @@ -29,3 +31,7 @@ There is a sample plugin called logging.py. Plugins are merely rq jobs that are ## RQ worker rq worker -u redis://127.0.0.1:6379/ + +# Deployment + +See examples in docs/examples directory. diff --git a/docs/examples/nginx/nginx.conf b/docs/examples/nginx/nginx.conf new file mode 100644 index 0000000..9435012 --- /dev/null +++ b/docs/examples/nginx/nginx.conf @@ -0,0 +1,17 @@ +server { + listen {{webportal_ip}}:80 default_server; + server_name _; + + location / { + # Must fix the HTTP_X_FORWARDED_FOR value in WSGI environ. + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-Server $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + if (!-f $request_filename) { + proxy_pass http://127.0.0.1:8080; + break; + } + } + +} diff --git a/docs/examples/supervisord/captiveportal.ini b/docs/examples/supervisord/captiveportal.ini new file mode 100644 index 0000000..9403169 --- /dev/null +++ b/docs/examples/supervisord/captiveportal.ini @@ -0,0 +1,14 @@ +[program:captiveportal] +command={{global_virtualenv_path}}/bin/gunicorn portal --workers 3 --log-level DEBUG --bind 127.0.0.1:8080 +directory=/var/opt/captiveportal/portal +pythonpath={{global_virtualenv_path}}/lib/python2.7/site-packages +user={{captiveportal_username}} +group=virtualenv +umask=002 +autostart=true +autorestart=true +stdout_logfile=/var/log/captiveportal_gunicorn.log +loglevel=debug +redirect_stderr=true +stopsignal=QUIT +environment=PATH={{global_virtualenv_path}}/bin:/bin:/sbin:/usr/bin:/usr/sbin diff --git a/docs/examples/supervisord/rqworker.ini b/docs/examples/supervisord/rqworker.ini new file mode 100644 index 0000000..ff289e5 --- /dev/null +++ b/docs/examples/supervisord/rqworker.ini @@ -0,0 +1,20 @@ +[program:rqworker] +; Also, you probably want to include a settings module to configure this +; worker. For more info on that, see http://python-rq.org/docs/workers/ +command={{global_virtualenv_path}}/bin/rq worker -u redis://127.0.0.1:6379/ +process_name=%(program_name)s +numprocs=1 + +; This is the directory from which RQ is ran. Be sure to point this to the +; directory where your source code is importable from +directory={{captiveportal_install_dir}}/portal + +; RQ requires the TERM signal to perform a warm shutdown. If RQ does not die +; within 10 seconds, supervisor will forcefully kill it +stopsignal=TERM + +autostart=true +autorestart=true +stdout_logfile=/var/log/rqworker_gunicorn.log +environment=PATH={{global_virtualenv_path}}/bin:/bin:/sbin:/usr/bin:/usr/sbin +