How to make Python Openshift run a specific python file?

I want to run a specific python file whenever an OpenShift application starts. I have tried many things, for example, in the wsgi.py file with execfile("thefilename.py"), which does not work!

I was hoping to help with this! Many thanks!

+4
source share
2 answers

Executed with a bash script.

#!/bin/bash

export LD_LIBRARY_PATH="/opt/rh/python33/root/usr/lib64"
export PATH="/var/lib/openshift/<your ssh id>/python//virtenv/venv/bin:/var/lib/openshift/<your ssh id>/python//bin:/opt/rh/python33/root/usr/bin:/bin:/usr/bin:/usr/sbin"
source ${VIRTUAL_ENV}/bin/activate
python pathtofile/yourfile.py
+1
source

Try this if you want to run in a python script. It should run the file in the background.

Import os
os.system("python  pathtofile/thefilename.py &")
0
source

All Articles