... | ... | @@ -67,6 +67,68 @@ Type "help", "copyright", "credits" or "license" for more information. |
|
|
>>>
|
|
|
```
|
|
|
|
|
|
### 3. Add `bin/python` command which will be used to setup the environment
|
|
|
### 3. Add `bin/python` command which will be used to setup the environment when Passenger launches the app
|
|
|
|
|
|
NGINX with Passenger is configured to execute `$APPROOT/bin/python` if this exists, so we can add environment modifications here. Following the example https://github.com/OSC/nginx_stage/blob/cc1398ed35214ed6bd774ffee93ad679e5f01cb0/bin/ood_ruby.example |
|
|
\ No newline at end of file |
|
|
NGINX with Passenger is configured to execute `$APPROOT/bin/python` if this exists, so we can add environment modifications here. Following the example https://github.com/OSC/nginx_stage/blob/cc1398ed35214ed6bd774ffee93ad679e5f01cb0/bin/ood_ruby.example
|
|
|
|
|
|
Add these contents to `bin/python` and make it executable (chmod 755):
|
|
|
|
|
|
```bash
|
|
|
#!/bin/bash
|
|
|
|
|
|
# following example https://github.com/OSC/nginx_stage/blob/cc1398ed35214ed6bd774ffee93ad679e5f01cb0/bin/ood_ruby.example
|
|
|
|
|
|
|
|
|
# python27
|
|
|
SCL_PKGS=${SCL_PKGS:-"nginx16 rh-passenger40 rh-ruby22 nodejs010 git19 python27"}
|
|
|
|
|
|
# python35
|
|
|
# SCL_PKGS=${SCL_PKGS:-"nginx16 rh-passenger40 rh-ruby22 nodejs010 git19 rh-python35"}
|
|
|
|
|
|
SCL_SOURCE=$(command -v scl_source)
|
|
|
[[ ${SCL_SOURCE} ]] && source ${SCL_SOURCE} enable ${SCL_PKGS}
|
|
|
|
|
|
|
|
|
# cd is piped to /dev/null in case cd outputs to STDOUT
|
|
|
# BINDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )"
|
|
|
BINDIR=`dirname "$(readlink -f "$0")"`
|
|
|
APPROOT=`dirname "$BINDIR"`
|
|
|
export PYTHONPATH=$APPROOT/.pip:$PYTHONPATH
|
|
|
|
|
|
exec /bin/env python "$@"
|
|
|
```
|
|
|
|
|
|
i.e.
|
|
|
|
|
|
```
|
|
|
efranz@webtest04:~/awesim/dev/hellopython (end_result)$ cat >bin/python <<EOL
|
|
|
> #!/bin/bash
|
|
|
>
|
|
|
> # following example https://github.com/OSC/nginx_stage/blob/cc1398ed35214ed6bd774ffee93ad679e5f01cb0/bin/ood_ruby.example
|
|
|
>
|
|
|
>
|
|
|
> # python27
|
|
|
> SCL_PKGS=${SCL_PKGS:-"nginx16 rh-passenger40 rh-ruby22 nodejs010 git19 python27"}
|
|
|
>
|
|
|
> # python35
|
|
|
> # SCL_PKGS=${SCL_PKGS:-"nginx16 rh-passenger40 rh-ruby22 nodejs010 git19 rh-python35"}
|
|
|
>
|
|
|
> SCL_SOURCE=$(command -v scl_source)
|
|
|
> [[ ${SCL_SOURCE} ]] && source ${SCL_SOURCE} enable ${SCL_PKGS}
|
|
|
>
|
|
|
>
|
|
|
> # cd is piped to /dev/null in case cd outputs to STDOUT
|
|
|
> # BINDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )"
|
|
|
> BINDIR=`dirname "$(readlink -f "$0")"`
|
|
|
> APPROOT=`dirname "$BINDIR"`
|
|
|
> export PYTHONPATH=$APPROOT/.pip:$PYTHONPATH
|
|
|
>
|
|
|
> exec /bin/env python "$@"
|
|
|
> EOL
|
|
|
efranz@webtest04:~/awesim/dev/hellopython (end_result)$ chmod 755 bin/python
|
|
|
efranz@webtest04:~/awesim/dev/hellopython (end_result)$
|
|
|
```
|
|
|
|
|
|
### 4. Access app URL to launch
|
|
|
|
|
|
Go to https://apps-test.awesim.org/pun/dev/hellopython or go to Develop->Sandbox Apps on the dashboard to launch app |
|
|
\ No newline at end of file |