zapty / forever-service

Provision node script as a service via forever, allowing it to automatically start on boot, working across various Linux distros and OS
https://github.com/zapty/forever-service
MIT License
594 stars 65 forks source link

envVars for Upstart handled with env stanzas #18

Closed andrew-vant closed 9 years ago

andrew-vant commented 9 years ago

Including envVars in the exec stanza, shell-style, doesn't work as expected.

More specifically: I was trying to use forever-service to run Ghost, which requires NODE_ENV=production as an environment variable, normally specified at the start of the command line as shown here. When I tried to install it as a service with forever-service, using -e to specify the variable, it failed on job start. Investigation indicated that the exec block was trying to treat 'NODE_ENV=production' as the executable, and of course not finding it.

I can't find anything in the documentation for upstart specifying whether initializing vars in an exec stanza that way should work or not, but this change sticks them in env stanzas and does work as expected. It will still fail if there are spaces in the values, since it uses spaces as a separator. There's probably a better way, but it functions.

I ran into this issue on ubuntu 14.04. If I'm understanding the mechanism correctly, it can probably be reproduced by almost anything that makes use of -e on an upstart platform.

arvind-agarwal commented 9 years ago

@andrew-vant Thanks for this request and fixing the issue.

arvind-agarwal commented 9 years ago

@andrew-vant I modified your code little bit to support env variables with space in the value (with quotes around them).