Parcourir la source

Finished up the python tests

Mike Smith il y a 10 ans
Parent
commit
812ae1fb7d

+ 5 - 3
frameworks/Python/uwsgi/bash_profile.sh

@@ -1,14 +1,16 @@
-export PY2_ROOT=$TROOT/py2
+export PY2_ROOT=$IROOT/py2
 export PY2=$PY2_ROOT/bin/python
 export PY2_PIP=$PY2_ROOT/bin/pip
 export PY2_GUNICORN=$PY2_ROOT/bin/gunicorn
 
-export PYPY_ROOT=$TROOT/pypy
+export PYPY_ROOT=$IROOT/pypy
 export PYPY=$PYPY_ROOT/bin/python
 export PYPY_PIP=$PYPY_ROOT/bin/pip
 export PYPY_GUNICORN=$PYPY_ROOT/bin/gunicorn
 
-export PY3_ROOT=$TROOT/py3
+export PY3_ROOT=$IROOT/py3
 export PY3=$PY3_ROOT/bin/python
 export PY3_PIP=$PY3_ROOT/bin/pip3
 export PY3_GUNICORN=$PY3_ROOT/bin/gunicorn
+
+export NGINX_HOME=${IROOT}/nginx

+ 1 - 8
frameworks/Python/uwsgi/install.sh

@@ -5,11 +5,4 @@ export PIP_DOWNLOAD_CACHE=$IROOT/.pip_cache
 
 fw_depends python2 nginx
 
-$IROOT/py2/bin/virtualenv $TROOT/py2
-$TROOT/py2/bin/pip install -r $TROOT/requirements.txt
-
-#$IROOT/py3/bin/python3 -m venv $TROOT/py3
-#$TROOT/py3/bin/pip install -r $TROOT/requirements.txt
-
-#$IROOT/pypy/bin/virtualenv $TROOT/pypy
-#$TROOT/pypy/bin/pip install -r $TROOT/requirements-pypy.txt
+$PY2_PIP install --install-option="--prefix=${PY2_ROOT}" -r $TROOT/requirements.txt

+ 0 - 26
frameworks/Python/uwsgi/setup.py

@@ -1,26 +0,0 @@
-import multiprocessing
-import subprocess
-import os
-
-uwsgi = os.path.expandvars('$PY2_ROOT/bin/uwsgi')
-PROCS = multiprocessing.cpu_count()
-
-
-def start(args, logfile, errfile):
-    # --http and --http-processes create http router processes that process the
-    # incoming connections and pass them to the worker processes (-p). We use
-    # PROCS number of http router processes so that a single router process
-    # doesn't become a bottleneck.
-    subprocess.Popen(
-        uwsgi + ' --master -L -l 5000 --gevent 1000 --http :8080 --http-keepalive ' +
-        ' --http-processes ' + str(PROCS) + ' -p ' + str(PROCS) + ' -w hello ' +
-        ' --add-header "Connection: keep-alive" ' +
-        ' --pidfile /tmp/uwsgi.pid',
-        shell=True, cwd="uwsgi", stderr=errfile, stdout=logfile)
-    return 0
-
-
-def stop(logfile, errfile):
-    subprocess.call(uwsgi + ' --stop /tmp/uwsgi.pid', shell=True, cwd="uwsgi", stderr=errfile, stdout=logfile)
-    os.system('killall uwsgi')
-    return 0

+ 3 - 0
frameworks/Python/uwsgi/setup.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+
+$PY2_ROOT/bin/uwsgi --master -L -l 5000 --gevent 1000 --http :8080 --http-keepalive --http-processes ${MAX_THREADS} -p ${MAX_THREADS} -w hello --add-header "Connection: keep-alive" --pidfile /tmp/uwsgi.pid &

+ 0 - 42
frameworks/Python/uwsgi/setup_nginx.py

@@ -1,42 +0,0 @@
-import subprocess
-import multiprocessing
-import os
-import time
-
-
-CWD = os.path.abspath(os.path.dirname(__file__))
-uwsgi = os.path.expandvars('$PY2_ROOT/bin/uwsgi')
-NCPU = multiprocessing.cpu_count()
-NGINX_COMMAND = 'sudo /usr/local/nginx/sbin/nginx -c ' + CWD + '/nginx.conf'
-
-
-def start(args, logfile, errfile):
-    try:
-        subprocess.check_call(
-            NGINX_COMMAND,
-            shell=True, stdout=logfile, stderr=errfile)
-
-        # Run in the background, but keep stdout/stderr for easy debugging.
-        # Note that this uses --gevent 1000 just like setup.py.
-        subprocess.Popen(
-            uwsgi + ' --ini uwsgi.ini' +
-            ' --processes ' + str(NCPU) +
-            ' --gevent 1000 --wsgi hello',
-            shell=True, cwd='uwsgi',
-            stdout=logfile, stderr=errfile)
-        time.sleep(3)
-        return 0
-    except subprocess.CalledProcessError:
-        return 1
-
-def stop(logfile, errfile):
-    subprocess.call(
-        NGINX_COMMAND + ' -s stop',
-        shell=True, stdout=logfile, stderr=errfile)
-
-    subprocess.call(
-        uwsgi + ' --stop /tmp/uwsgi.pid',
-        shell=True, cwd="uwsgi", stderr=errfile, stdout=logfile)
-
-    time.sleep(3)
-    return 0

+ 5 - 0
frameworks/Python/uwsgi/setup_nginx.sh

@@ -0,0 +1,5 @@
+#!/bin/bash
+
+$NGINX_HOME/sbin/nginx -c ${TROOT}/nginx.conf
+
+$PY2_ROOT/bin/uwsgi --ini uwsgi.ini --processes ${MAX_THREADS} --gevent 1000 --wsgi hello &

+ 5 - 3
frameworks/Python/wsgi/bash_profile.sh

@@ -1,14 +1,16 @@
-export PY2_ROOT=$TROOT/py2
+export PY2_ROOT=$IROOT/py2
 export PY2=$PY2_ROOT/bin/python
 export PY2_PIP=$PY2_ROOT/bin/pip
 export PY2_GUNICORN=$PY2_ROOT/bin/gunicorn
 
-export PYPY_ROOT=$TROOT/pypy
+export PYPY_ROOT=$IROOT/pypy
 export PYPY=$PYPY_ROOT/bin/python
 export PYPY_PIP=$PYPY_ROOT/bin/pip
 export PYPY_GUNICORN=$PYPY_ROOT/bin/gunicorn
 
-export PY3_ROOT=$TROOT/py3
+export PY3_ROOT=$IROOT/py3
 export PY3=$PY3_ROOT/bin/python
 export PY3_PIP=$PY3_ROOT/bin/pip3
 export PY3_GUNICORN=$PY3_ROOT/bin/gunicorn
+
+export NGINX_HOME=${IROOT}/nginx

+ 1 - 8
frameworks/Python/wsgi/install.sh

@@ -5,11 +5,4 @@ export PIP_DOWNLOAD_CACHE=$IROOT/.pip_cache
 
 fw_depends python2 nginx
 
-$IROOT/py2/bin/virtualenv $TROOT/py2
-$TROOT/py2/bin/pip install -r $TROOT/requirements.txt
-
-#$IROOT/py3/bin/python3 -m venv $TROOT/py3
-#$TROOT/py3/bin/pip install -r $TROOT/requirements.txt
-
-#$IROOT/pypy/bin/virtualenv $TROOT/pypy
-#$TROOT/pypy/bin/pip install -r $TROOT/requirements-pypy.txt
+$PY2_PIP install --install-option="--prefix=${PY2_ROOT}" -r $TROOT/requirements.txt

+ 2 - 0
frameworks/Python/wsgi/requirements.txt

@@ -2,3 +2,5 @@ ujson==1.33
 uwsgi
 gunicorn==19.1
 meinheld==0.5.6
+
+greenlet==0.4.4

+ 0 - 21
frameworks/Python/wsgi/setup.py

@@ -1,21 +0,0 @@
-import os
-import subprocess
-import time
-
-CWD = os.path.dirname(__file__)
-
-
-def start(args, logfile, errfile):
-    subprocess.Popen(
-        "$PY2_GUNICORN hello:app -c gunicorn_conf.py",
-        cwd=CWD, stderr=errfile, stdout=logfile, shell=True)
-    time.sleep(3)
-    return 0
-
-
-def stop(logfile, errfile):
-    subprocess.call(
-        "kill `cat gunicorn.pid`",
-        cwd=CWD, stderr=errfile, stdout=logfile, shell=True)
-    time.sleep(3)
-    return 0

+ 3 - 0
frameworks/Python/wsgi/setup.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+
+$PY2_GUNICORN hello:app -c gunicorn_conf.py &

+ 0 - 39
frameworks/Python/wsgi/setup_nginxuwsgi.py

@@ -1,39 +0,0 @@
-import subprocess
-import multiprocessing
-import os
-import time
-
-
-CWD = os.path.abspath(os.path.dirname(__file__))
-bin_dir = os.path.expandvars('$PY2_ROOT/bin')
-NCPU = multiprocessing.cpu_count()
-NGINX_COMMAND = 'sudo /usr/local/nginx/sbin/nginx -c ' + CWD + '/nginx.conf'
-
-
-def start(args, logfile, errfile):
-    try:
-        subprocess.check_call(
-            NGINX_COMMAND,
-            shell=True, stdout=logfile, stderr=errfile)
-
-        # Run in the background, but keep stdout/stderr for easy debugging
-        subprocess.Popen(
-            bin_dir + '/uwsgi --ini uwsgi.ini' +
-            ' --processes ' + str(NCPU) +
-            ' --wsgi hello:app',
-            shell=True, cwd=CWD, stdout=logfile, stderr=errfile)
-        time.sleep(3)
-        return 0
-    except subprocess.CalledProcessError:
-        return 1
-
-def stop(logfile, errfile):
-    subprocess.check_call(
-        NGINX_COMMAND + ' -s stop',
-        shell=True, stdout=logfile, stderr=errfile)
-
-    subprocess.call(
-        bin_dir + '/uwsgi --stop /tmp/uwsgi.pid',
-        shell=True, cwd=CWD, stderr=errfile, stdout=logfile)
-    time.sleep(3)
-    return 0

+ 5 - 0
frameworks/Python/wsgi/setup_nginxuwsgi.sh

@@ -0,0 +1,5 @@
+#!/bin/bash
+
+$NGINX_HOME/sbin/nginx -c $TROOT/nginx.conf
+
+$PY2_ROOT/bin/uwsgi --ini uwsgi.ini --processes ${MAX_THREADS} --wsgi hello:app &