aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2014-10-09 18:33:02 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2014-10-10 14:42:17 -0500
commitae361ba126522958cc4e0312dcc14aa752e0e65a (patch)
tree00b5703c71f4fb200137764fb00f83815c3a7a32
parent227a81b534c2f77f6cdb10a5936c6b1dfb8c3ec6 (diff)
downloadmediagoblin-ae361ba126522958cc4e0312dcc14aa752e0e65a.tar.lz
mediagoblin-ae361ba126522958cc4e0312dcc14aa752e0e65a.tar.xz
mediagoblin-ae361ba126522958cc4e0312dcc14aa752e0e65a.zip
Use python imports to determine whether or not we're using gunicorn
This commit sponsored by Andrés Muñiz Piniella. Thank you!
-rw-r--r--lazystarter.sh.in28
1 files changed, 24 insertions, 4 deletions
diff --git a/lazystarter.sh.in b/lazystarter.sh.in
index 218f738f..f8da8aef 100644
--- a/lazystarter.sh.in
+++ b/lazystarter.sh.in
@@ -16,13 +16,33 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-use_python3=@USE_PYTHON3@
-
selfname=$(basename "$0")
local_bin="./bin"
+
+# Test whether or not gunicorn is installed
+# -----------------------------------------
+if [ -f "${local_bin}/python" ]; then
+ our_python="${local_bin}/python";
+else
+ our_python="python";
+fi
+
+if $our_python -c "import sys
+try:
+ import gunicorn
+ sys.exit(0)
+except ImportError:
+ sys.exit(1)
+"; then
+ use_gunicorn=true;
+else
+ use_gunicorn=false;
+fi
+# -----------------------------------------
+
case "$selfname" in
lazyserver.sh)
- if $use_python3; then
+ if $use_gunicorn; then
starter_cmd=gunicorn;
else
starter_cmd=paster;
@@ -76,7 +96,7 @@ set -x
export CELERY_ALWAYS_EAGER=true
case "$selfname" in
lazyserver.sh)
- if $use_python3; then
+ if $use_gunicorn; then
$starter --paste "$ini_file" --log-file=- $@;
else
$starter serve "$ini_file" "$@" --reload;