Created
September 9, 2014 10:49
-
-
Save vigneshsarma/f31fcffde04f26c44744 to your computer and use it in GitHub Desktop.
Can be use to reproduce the bug https://github.com/unbit/uwsgi/issues/706
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
#!/usr/bin/env bash | |
uwsgi_ini="$( cat <<EOF | |
[uwsgi] | |
http = :8902 | |
thunder-lock = true | |
processes = 2 | |
master = true | |
pidfile = /tmp/uwsgi.pid | |
module = sample.wsgi | |
chdir = /tmp/sample/current | |
logto = /tmp/uwsgi_main.log | |
single-interpreter = true | |
enable-threads = true | |
die-on-term = true | |
EOF | |
)" | |
alias tail_uwsgi_logs='tail -f /tmp/uwsgi_main.log' | |
function create_app() { | |
app_name=$1 | |
cd /tmp/sample/builds | |
django-admin.py startproject sample | |
cd sample | |
echo -e "$uwsgi_ini" > uwsgi.ini | |
echo "home = $VIRTUAL_ENV" >> uwsgi.ini | |
cd /tmp/sample | |
# rename | |
mv /tmp/sample/builds/sample /tmp/sample/builds/$app_name | |
echo ln -sfn /tmp/sample/builds/$app_name /tmp/sample/current | |
ln -sfn /tmp/sample/builds/$app_name /tmp/sample/current | |
} | |
function setup1() { | |
# except virtualenvwrapper to be present | |
mkvirtualenv uwsgi_sample | |
# use tmp for working directory | |
cd /tmp | |
mkdir -p /tmp/sample/builds/ | |
pip install Django | |
# on os x, might need before installing uWSGI | |
C_INCLUDE_PATH=/usr/local/include LIBRARY_PATH=/usr/local/lib pip install uWSGI | |
create_app sample1 | |
} | |
function start_uwsgi() { | |
cd /tmp/sample/current | |
uwsgi --ini uwsgi.ini & | |
cd /tmp | |
tail_uwsgi_logs | |
} | |
function reload_uwsgi() { | |
kill -HUP `cat /tmp/uwsgi.pid` | |
tail_uwsgi_logs | |
} | |
function kill_uwsgi() { | |
kill `cat /tmp/uwsgi.pid` | |
tail_uwsgi_logs | |
} | |
function cleanup() { | |
deactivate | |
rmvirtualenv uwsgi_sample | |
cd /tmp | |
rm -vr /tmp/sample/ | |
} | |
# steps to reproduce the bug, | |
setup1 | |
echo "Ctrl+c to exit tail" | |
start_uwsgi | |
create_app sample2 | |
reload_uwsgi | grep chdir | |
# you will notice the chdir in the logs. | |
kill_uwsgi | |
cleanup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment