-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from BenjamenMeyer/bugfix_update_examples
Bug Fix: Updated examples per new infrastructure
- Loading branch information
Showing
15 changed files
with
366 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
======== | ||
Examples | ||
======== | ||
|
||
The foldlers here contain examples of how to run the | ||
StackInAWSGI functionality in some common WSGI servers. | ||
|
||
gunicorn | ||
-------- | ||
|
||
Shows how to run StackInAWSGI using Gunicorn. | ||
|
||
uwsgi | ||
----- | ||
|
||
Shows how to run StackInAWSGI using uWSGI. | ||
|
||
python-wsgiref | ||
-------------- | ||
|
||
Shows how to run StackInAWSGI using the built-in wsgiref. | ||
|
||
|
||
Known Issues | ||
============ | ||
|
||
- Only 1 worker can be used for any given WSGI server platform. | ||
This is due to the fact that the session information is not | ||
shared between workers. In theory all the workers should be able | ||
to see the data; however, they may be running as separate processes | ||
which would limit their value of what they can see. More research | ||
is needed to overcome this limitation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
""" | ||
Gunicorn Example App | ||
""" | ||
import logging | ||
|
||
from stackinabox.services.hello import HelloService | ||
|
||
from stackinawsgi import App | ||
|
||
app = App([HelloService()]) | ||
app.StackInABoxUriUpdate('localhost:8081') | ||
lf = logging.FileHandler('stackinawsgi.log') | ||
lf.setLevel(logging.DEBUG) | ||
log = logging.getLogger() | ||
log.addHandler(lf) | ||
log.setLevel(logging.DEBUG) | ||
|
||
app = App([HelloService]) | ||
app.StackInABoxUriUpdate('http://localhost:8081') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,51 @@ | ||
#!/bin/bash | ||
|
||
# Note: Until Issue #11 (Session Bug) is fully resolved, | ||
# Stack-In-A-WSGI only supports a single worker, | ||
# each worker will have its own session data completely | ||
# independent of all other workers. | ||
WORKER_COUNT=1 | ||
VENV_DIR="gunicorn_example_app" | ||
|
||
for ARG in ${@} | ||
do | ||
echo "Found argument: ${ARG}" | ||
if [ "${ARG}" == "--reset" ]; then | ||
echo " User requested virtualenv reset, long argument name" | ||
let -i RESET_VENV=1 | ||
elif ["${ARG}" == "-r" ]; then | ||
echo " User requested virtualenv reset, short argument name" | ||
let -i RESET_VENV=2 | ||
fi | ||
done | ||
|
||
MD5SUM_ROOT=`ls / | md5sum | cut -f 1 -d ' '` | ||
MD5SUM_VENV=`ls ${VENV_DIR} | md5sum | cut -f 1 -d ' '` | ||
if [ "${MD5SUM_ROOT}" == "${MD5SUM_VENV}" ]; then | ||
echo "Virtual Environment target is root. Configuration not supported." | ||
exit 1 | ||
fi | ||
|
||
if [ -v RESET_VENV ]; then | ||
echo "Checking for existing virtualenv to remove..." | ||
if [ -d ${VENV_DIR} ]; then | ||
echo "Removing virtualenv ${VENV_DIR}..." | ||
rm -Rf ${VENV_DIR} | ||
fi | ||
fi | ||
|
||
if [ ! -d ${VENV_DIR} ]; then | ||
echo "Building virtualenv..." | ||
virtualenv ${VENV_DIR} | ||
|
||
INITIALIZE_VENV=1 | ||
fi | ||
|
||
|
||
source ${VENV_DIR}/bin/activate | ||
|
||
if [ -v INITIALIZE_VENV ]; then | ||
pip install -r requirements.txt | ||
fi | ||
|
||
echo "Starting new instances..." | ||
gunicorn -b 127.0.0.1:8081 -w 16 --error-logfile app-errors.log --access-logfile app-access.log --log-level DEBUG -D app:app | ||
gunicorn -b 127.0.0.1:8081 -w ${WORKER_COUNT} --error-logfile app-errors.log --access-logfile app-access.log --log-level DEBUG -D app:app |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
""" | ||
Python WSGI-Ref Example App | ||
""" | ||
import logging | ||
|
||
from stackinabox.services.hello import HelloService | ||
|
||
from stackinawsgi import App | ||
|
||
lf = logging.FileHandler('python-wsgi-ref.log') | ||
lf.setLevel(logging.DEBUG) | ||
log = logging.getLogger() | ||
log.addHandler(lf) | ||
log.setLevel(logging.DEBUG) | ||
|
||
app = App([HelloService]) | ||
app.StackInABoxUriUpdate('localhost:8081') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
pywsgiref_stop.sh | ||
pywsgiref_start.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
|
||
# Note: Until Issue #11 (Session Bug) is fully resolved, | ||
# Stack-In-A-WSGI only supports a single worker, | ||
# each worker will have its own session data completely | ||
# independent of all other workers. | ||
WORKER_COUNT=1 | ||
VENV_DIR="pywsgiref_example_app" | ||
|
||
for ARG in ${@} | ||
do | ||
echo "Found argument: ${ARG}" | ||
if [ "${ARG}" == "--reset" ]; then | ||
echo " User requested virtualenv reset, long argument name" | ||
let -i RESET_VENV=1 | ||
elif ["${ARG}" == "-r" ]; then | ||
echo " User requested virtualenv reset, short argument name" | ||
let -i RESET_VENV=2 | ||
fi | ||
done | ||
|
||
MD5SUM_ROOT=`ls / | md5sum | cut -f 1 -d ' '` | ||
MD5SUM_VENV=`ls ${VENV_DIR} | md5sum | cut -f 1 -d ' '` | ||
if [ "${MD5SUM_ROOT}" == "${MD5SUM_VENV}" ]; then | ||
echo "Virtual Environment target is root. Configuration not supported." | ||
exit 1 | ||
fi | ||
|
||
if [ -v RESET_VENV ]; then | ||
echo "Checking for existing virtualenv to remove..." | ||
if [ -d ${VENV_DIR} ]; then | ||
echo "Removing virtualenv ${VENV_DIR}..." | ||
rm -Rf ${VENV_DIR} | ||
fi | ||
fi | ||
|
||
if [ ! -d ${VENV_DIR} ]; then | ||
echo "Building virtualenv..." | ||
virtualenv ${VENV_DIR} | ||
|
||
INITIALIZE_VENV=1 | ||
fi | ||
|
||
source ${VENV_DIR}/bin/activate | ||
|
||
if [ -v INITIALIZE_VENV ]; then | ||
pip install -r requirements.txt | ||
fi | ||
|
||
echo "Starting new instances..." | ||
python wsgiserver.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
echo "Stopping existing instances..." | ||
kill -3 `ps -Aef | grep wsgiserver.py | grep -v grep | tr -s ' ' ';' | cut -f 2 -d ';'` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-e ../../ | ||
-e git+https://github.com/TestInABox/stackInABox#egg=stackinabox-0.10a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from __future__ import absolute_import | ||
|
||
from wsgiref.simple_server import make_server | ||
|
||
import app | ||
|
||
|
||
httpd = make_server('localhost', 8081, app.app) | ||
httpd.serve_forever() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
""" | ||
Gunicorn Example App | ||
""" | ||
import logging | ||
|
||
from stackinabox.services.hello import HelloService | ||
|
||
from stackinawsgi import App | ||
|
||
app = App([HelloService()]) | ||
app.StackInABoxUriUpdate('localhost:8081') | ||
lf = logging.FileHandler('stackinawsgi.log') | ||
lf.setLevel(logging.DEBUG) | ||
log = logging.getLogger() | ||
log.addHandler(lf) | ||
log.setLevel(logging.DEBUG) | ||
|
||
app = App([HelloService]) | ||
app.StackInABoxUriUpdate('http://localhost:8081') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.