On Mar 24, 2008, at 9:00 PM, Mohanaraj Gopala Krishnan wrote:
> On Tue, Mar 25, 2008 at 1:34 AM, Roger Hoover  
> <[EMAIL PROTECTED]> wrote:
>> Another option is to use a template engine such as Perl Template  
>> Toolkit  or
>> Cheetah to expand environment variables first and generate your  
>> supervisord
>> config file.
>
> That pretty much the path I have taken.
>
> What I also found is that adding environment variables to the command
> value also do not get replaced, unlike how it would if you were to run
> the command straight of the shell. For e.g.
>
> command=this_is_my_command $USER
>
> If you were to run that off the shell directly the $USER  variable
> gets replaced. This does not happen when run through supervisord. YOu
> end up with the literal $USER being passed to the command.
>
> Or am I missing something ?

No, you're right.  Unlike a shell, supervisor does no environment  
variable expansion in commands.  There are a limited set of Python  
string interpolatables you can put in there (like %(here)s,  
representing the directory in which the config file lives).  These are  
documented in the manual, but they are not related to shell-style  
environment variable expansion.  You'll need to write a wrapper shell  
script to expand shell variables.

Note however, though (and this is also documented in the manual), that  
supervisor *does not* invoke a shell to start the commands, so $USER  
may not be what you expect even in a wrapper shell script.  You'll  
need to set these manually in an environment= line within the program  
config.

In general, a program which runs under supervisor should not depend on  
the composition (or existence) of any environment variables resolved  
when .bashrc, .profile et. al. are run, as supervisor just doesn't  
invoke them.

- C
_______________________________________________
Supervisor-users mailing list
[email protected]
http://lists.supervisord.org/mailman/listinfo/supervisor-users

Reply via email to