nickstenning / honcho

Honcho: a python clone of Foreman. For managing Procfile-based applications.
http://pypi.python.org/pypi/honcho
MIT License
1.59k stars 145 forks source link

Fix quoting of special env var values in Upstart configs #171

Closed nickstenning closed 8 years ago

nickstenning commented 8 years ago

As reported by #151, the quoting of environment variable values in Upstart configs is currently broken in the general case.

Correctly quoting variable values in the current context (i.e. already inside single quotes) is possible, but extremely messy, and results in hugely nested quotes when those values contain single quotes.

Instead, move the definition of the environment variables into the body of the Upstart config using the env directive, and add the -m option to su(1) so that environment variables are passed through to the shell process.

Closes #151. Closes #154.

nickstenning commented 8 years ago

@migurski Could you check this out and let me know if it correctly addresses the issue for you?

migurski commented 8 years ago

Thanks Nick! I checked again with Python 2.7.6 on Ubuntu 14.04. At 84a1f7d it generated a correct script, at d8be8f4 and it generated a bad one, and with your recent efd6292 and it generated this improved working script:

start on starting honcho-stuff
stop on stopping honcho-stuff
respawn

env VAR='foo bar'
env PORT=5000

exec su - migurski -m -s /bin/sh -c 'cd /home/migurski/honcho; exec python /home/migurski/honcho/stuff.py >> /var/log/honcho/stuff-1.log 2>&1'
migurski commented 8 years ago

I’ve updated https://github.com/nickstenning/honcho/pull/154, though with the file honcho/test/integration/test_export.py gone I’m not sure it will have an effect.

nickstenning commented 8 years ago

Thanks for the feedback @migurski. This'll be in the next release.