Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support running of an app.sh script. #126

Closed
GrahamDumpleton opened this issue Jun 14, 2016 · 2 comments
Closed

Support running of an app.sh script. #126

GrahamDumpleton opened this issue Jun 14, 2016 · 2 comments
Assignees
Labels

Comments

@GrahamDumpleton
Copy link
Contributor

First raised as comment against separate issue:

but breaking out as independent issue.

The ability to provide an app.sh file makes things easier when wishing to run an alternate WSGI server such as uWSGI or Waitress where there may not be a way to start it up by importing a Python module and executing some API.

Right now you would have to do the following.

1 - Create a wsgi.py file with your WSGI application.

2 - Create an app.py file containing:

import os

os.execl('/opt/app-root/src/app.sh', 'uwsgi')

3 - Create an app.sh file containing:

#!/bin/bash

exec uwsgi \
    --http-socket :8080 \
    --die-on-term \
    --master \
    --single-interpreter \
    --enable-threads \
    --threads=5 \
    --thunder-lock \
    --module wsgi

The reason for using the app.sh in this case is so that PATH searching for uwsgi program can be relied on. If you try and launch uwsgi from app.py, because os.exec calls require fill path, you have to either hardwire the path, the location of which would change if a switch is made to a Python virtual environment rather than per user site-packages, or you have to add a Python function to search PATH yourself.

Far simpler to add support for app.sh. So something like the following, which would go before existing check and execution of app.py.

APP_SCRIPT="${APP_SCRIPT:-app.sh}"
if [[ -x "$APP_SCRIPT" ]]; then
  echo "---> Running application from script ($APP_SCRIPT) ..."
  exec "$APP_SCRIPT"
fi

In general, easier to use shell script rather than Python code to do special stuff prior to executing command line based server.

@bparees bparees self-assigned this Jun 14, 2016
@bparees bparees added the P2 Priority 2 label Jun 14, 2016
@bparees
Copy link
Collaborator

bparees commented Jun 14, 2016

@GrahamDumpleton you want to submit a PR updating the run script(s)?

@pkubatrh
Copy link
Member

pkubatrh commented Feb 6, 2017

Implemented by #174

@pkubatrh pkubatrh closed this as completed Feb 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants