From 413db68249eb25ee52bc729aff4b642ef09c49d1 Mon Sep 17 00:00:00 2001 From: John Andersen Date: Mon, 26 Sep 2016 16:21:43 +0000 Subject: [PATCH] Additions to documentation and configs Removed unused modules from requirements.txt cupshelpers louis lxml pycups pycurl pygobject team Added nginx.conf as an example of how to configure uwsgi with nginx. This can be dropped in as a replacement for pxe nginx config file as it includes both locations. Added isic_uwsgi.service file to be placed in /etc/systemd/service/ to start the uwsgi app. Added SUBDIR to settings.py so that the uwsgi app responds to requests when it is served under the /icis subdirectory. Signed-off-by: John Andersen --- README => README.rst | 27 ++++++++++++++++++++++++++- app.py | 15 +++++++-------- icis_uwsgi.service | 13 +++++++++++++ nginx.conf | 18 ++++++++++++++++++ requirements.txt | 7 ------- settings.py | 1 + 6 files changed, 65 insertions(+), 16 deletions(-) rename README => README.rst (61%) create mode 100644 icis_uwsgi.service create mode 100644 nginx.conf diff --git a/README b/README.rst similarity index 61% rename from README rename to README.rst index 40ca194..3800c36 100644 --- a/README +++ b/README.rst @@ -1,5 +1,5 @@ Ister Cloud Init Service -======================= +======================== This little web application is intended to be a helper for standing up up n-node clusters of Clear Linux. It complements the Clear Linux @@ -34,3 +34,28 @@ Standing up the web app (high level) # Test web-app curl localhost/icis/get_role/compute + +.. code-block:: console + + mkdir -pv /var/www + mkdir -pv /var/log/uwsgi + chown httpd:httpd /var/log/uwsgi + cd /var/www/ + git clone https://github.com/clearlinux/ister-cloud-init-svc + chown -R httpd:httpd /var/www + cd ister-cloud-init-svc + # Install python if you are on clear and don't have it already this bundle + # has it + swupd bundle-add os-core-dev + virtualenv .venv + . .venv/bin/activate + pip install -r requirements.txt + ln -s /var/www/ister-cloud-init-svc/icis_uwsgi.service \ + /etc/systemd/system/icis_uwsgi.service + # If you are using nginx then obviously don't trash your current config, use + # this as a guide instead + cp /var/www/ister-cloud-init-svc/nginx.conf /etc/nginx/nginx.conf + systemctl daemon-reload + systemctl restart nginx icis_uwsgi + # Verify it reponds + curl http://localhost/icis/get_role/compute diff --git a/app.py b/app.py index ca024a0..d3e3151 100644 --- a/app.py +++ b/app.py @@ -15,7 +15,7 @@ # from flask import Flask, abort, request, jsonify -from settings import APP_STATIC +from settings import APP_STATIC, SUBDIR import os import re @@ -50,13 +50,13 @@ def get_config_data(mac_addr): return None -@app.route('/') +@app.route(SUBDIR + '/') def index(): return 'Clear Cloud Init Service... is alive\n' -@app.route('/get_config/') -@app.route('/get_config/') +@app.route(SUBDIR + '/get_config/') +@app.route(SUBDIR + '/get_config/') def get_config(mac_addr=None): reply = None if mac_addr is None: @@ -71,8 +71,8 @@ def get_config(mac_addr=None): abort(404) -@app.route('/get_role/') -@app.route('/get_role/') +@app.route(SUBDIR + '/get_role/') +@app.route(SUBDIR + '/get_role/') def get_role(role=None): reply = None if role is None: @@ -89,5 +89,4 @@ def get_role(role=None): if __name__ == '__main__': - app.run(debug=True) - + app.run() diff --git a/icis_uwsgi.service b/icis_uwsgi.service new file mode 100644 index 0000000..4f6d75f --- /dev/null +++ b/icis_uwsgi.service @@ -0,0 +1,13 @@ +[Unit] +Description=ISTER uWSGI service + +[Service] +Type=notify +ExecStart=/usr/bin/uwsgi --ini /var/www/ister-cloud-init-svc/icis_uwsgi.ini \ + -H /var/www/ister-cloud-init-svc/.venv/ +Restart=always +KillSignal=SIGQUIT +NotifyAccess=all + +[Install] +WantedBy=multi-user.target diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..8b8df70 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,18 @@ +server { + listen 80; + server_name hostname; + server_name_in_redirect off; + location / { + root /var/www/pxe; + autoindex on; + index index.html index.htm; + } + location /icis/static/ { + rewrite ^/icis/static(/.*)$ $1 break; + root /var/www/ister-cloud-init-svc/static/; + } + location /icis/ { + uwsgi_pass unix:///var/www/ister-cloud-init-svc/icis_uwsgi.sock; + include uwsgi_params; + } +} diff --git a/requirements.txt b/requirements.txt index 5214855..5307ad6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,6 @@ Babel==2.1.1 cffi==1.5.2 chardet==2.3.0 cryptography==1.2.3 -cupshelpers==1.0 docutils==0.12 Flask==0.10.1 idna==2.0 @@ -13,8 +12,6 @@ itsdangerous==0.24 Jinja2==2.8 lazy-object-proxy==1.2.1 livereload==2.4.0 -louis==2.6.5 -lxml==3.5.0 MarkupSafe==0.23 netifaces==0.10.4 packaging==16.5 @@ -23,11 +20,8 @@ pep8==1.7.0 ply==3.8 pyasn1==0.1.9 pycparser==2.14 -pycups==1.9.73 -pycurl==7.43.0 pyelftools==0.23 Pygments==2.0.2 -pygobject==3.18.2 pylint==1.5.4 pyOpenSSL==0.15.1 pyparsing==2.1.0 @@ -41,7 +35,6 @@ snowballstemmer==1.2.0 Sphinx==1.3.2 sphinx-autobuild==0.5.2 sphinx-rtd-theme==0.1.9 -team==1.0 tornado==4.3 urllib3==1.14 urwid==1.3.1 diff --git a/settings.py b/settings.py index 9213db2..458bc6d 100644 --- a/settings.py +++ b/settings.py @@ -4,3 +4,4 @@ import os # APP_ROOT = application_top APP_ROOT = os.path.dirname(os.path.abspath(__file__)) APP_STATIC = os.path.join(APP_ROOT, 'static') +SUBDIR = '/icis'