Fix the supervisord template.

The script was relying on the presence of an environment variable, which
is only set when the virtualenv is activated. But a virtualenv does not
have to be activated to work (it's possible to call the python command
directly).

This fixes it by relying on `sys.executable` which should be correct at
all times.

Fixes #306
This commit is contained in:
Alexis Métaireau 2018-01-05 22:36:31 +01:00
parent 34a2161650
commit 0504fd82f5
2 changed files with 4 additions and 2 deletions

View file

@ -1,5 +1,5 @@
[program:ihatemoney]
command={{ venv_path }}/bin/gunicorn -c /etc/ihatemoney/gunicorn.conf.py ihatemoney.wsgi:application
command={{ bin_path }}/gunicorn -c /etc/ihatemoney/gunicorn.conf.py ihatemoney.wsgi:application
user=ihatemoney
autostart=true
autorestart=true

View file

@ -49,9 +49,11 @@ class GenerateConfig(Command):
os.path.join('conf-templates/', config_file) + '.j2'
).decode('utf-8')
bin_path = os.path.dirname(sys.executable)
print(Template(template_content).render(
pkg_path=os.path.abspath(os.path.dirname(__file__)),
venv_path=os.environ.get('VIRTUAL_ENV'),
bin_path=bin_path,
secret_key=self.gen_secret_key(),
))