Browse Source

Updated bottle

msmith-techempower 10 years ago
parent
commit
48ff5e0c12

+ 2 - 0
frameworks/Python/bottle/bash_profile.sh

@@ -12,3 +12,5 @@ export PY3_ROOT=$TROOT/py3
 export PY3=$PY3_ROOT/bin/python
 export PY3_PIP=$PY3_ROOT/bin/pip
 export PY3_GUNICORN=$PY3_ROOT/bin/gunicorn
+
+export NGINX_HOME=$IROOT/nginx

+ 0 - 18
frameworks/Python/bottle/setup.py

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

+ 0 - 35
frameworks/Python/bottle/setup_nginxuwsgi.py

@@ -1,35 +0,0 @@
-import subprocess
-import multiprocessing
-import os
-
-
-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.call(
-            NGINX_COMMAND,
-            shell=True, stdout=logfile, stderr=errfile)
-
-        # Run in the background, but keep stdout/stderr for easy debugging
-        subprocess.Popen(
-            "{0}/uwsgi --ini uwsgi.ini --processes {1} --wsgi app:app".format(
-                bin_dir, NCPU*3),
-            shell=True, cwd=CWD, stderr=errfile, stdout=logfile)
-        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(bin_dir + '/uwsgi --stop /tmp/uwsgi.pid',
-                    shell=True, stderr=errfile, stdout=logfile)
-    return 0

+ 6 - 0
frameworks/Python/bottle/setup_nginxuwsgi.sh

@@ -0,0 +1,6 @@
+#!/bin/bash
+
+sed -i 's|include .*/conf/uwsgi_params;|include '"${NGINX_HOME}"'/conf/uwsgi_params;|g' nginx.conf
+
+${NGINX_HOME}/sbin/nginx -c ${TROOT}/nginx.conf
+${PY2_ROOT}/bin/uwsgi --ini ${TROOT}/uwsgi.ini --processes ${MAX_THREADS} --wsgi app:app &

+ 0 - 18
frameworks/Python/bottle/setup_py3.py

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

+ 3 - 0
frameworks/Python/bottle/setup_py3.sh

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

+ 0 - 18
frameworks/Python/bottle/setup_pypy.py

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

+ 3 - 0
frameworks/Python/bottle/setup_pypy.sh

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