mirror of https://gerrit.hackerspace.pl/hscloud
47 lines
1.1 KiB
Python
47 lines
1.1 KiB
Python
import configparser
|
|
import os
|
|
import subprocess
|
|
import tempfile
|
|
|
|
import bazel_tools
|
|
import bazel_tools.tools.python
|
|
|
|
from bazel_tools.tools.python.runfiles import runfiles
|
|
r = runfiles.Create()
|
|
|
|
uwsgi = r.Rlocation("pydeps_pypi__uWSGI_2_0_18/uWSGI-2.0.18.data/scripts/uwsgi")
|
|
print(uwsgi)
|
|
settings = r.Rlocation("hscloud/personal/q3k/djtest/djtest/settings.py")
|
|
print(settings)
|
|
|
|
apppath = os.path.dirname(settings)
|
|
sitepath = os.path.dirname(apppath)
|
|
|
|
pythonpath = os.environ['PYTHONPATH']
|
|
|
|
# Make UWSGI ini config file
|
|
cfgf = tempfile.NamedTemporaryFile(mode='w', delete=False)
|
|
|
|
config = configparser.ConfigParser()
|
|
config['uwsgi'] = {}
|
|
config['uwsgi']['master'] = '1'
|
|
config['uwsgi']['chdir'] = sitepath
|
|
config['uwsgi']['module'] = 'djtest.wsgi'
|
|
config['uwsgi']['env'] = 'DJANGO_SETTINGS_MODULE=djtest.settings'
|
|
config['uwsgi']['http'] = '127.0.0.1:8080'
|
|
config['uwsgi']['pythonpath'] = pythonpath
|
|
|
|
config.write(cfgf)
|
|
cfgf.close()
|
|
|
|
args = [
|
|
# uwsgi from runfiles is non-chmodded, run through interpreter
|
|
'/lib64/ld-linux-x86-64.so.2',
|
|
uwsgi,
|
|
'--ini', cfgf.name,
|
|
]
|
|
|
|
subprocess.call(args)
|
|
|
|
os.unlink(cfgf.name)
|