http://docs.dotcloud.com/guides/daemons/ states:
Configuring The Environment
You can easily modify the environment of execution of your daemon with the “directory” and “environment” directives to change the directory where the command is executed and to define additional environment variable. For example:
[program:daemonname]
command = php my_daemon.php
directory = /home/dotcloud/current/
environment = QUEUE=*, VERBOSE=TRUE
However, I'm finding my PYTHONPATH environment variable is not being set:
dotcloud.yml:
www:
type: python
db:
type: postgresql
worker:
type: python-worker
supervisord.conf:
[program:apnsd]
command=/home/dotcloud/current/printenv.py
environment=PYTHONPATH=/home/dotcloud/current/apnsd/
printenv.py
#! /home/dotcloud/env/bin/python
import os
print "ENVIRONMENT"
print os.environ
the logs:
ENVIRONMENT
{'SUPERVISOR_ENABLED': '1', 'SUPERVISOR_SERVER_URL': 'unix:///var/dotcloud/super
visor.sock', 'VERBOSE': 'no', 'UPSTART_INSTANCE': '', 'PYTHONPATH': '/', 'PREVLE
VEL': 'N', 'UPSTART_EVENTS': 'runlevel', '/': '/', 'SUPERVISOR_PROCESS_NAME': 'a
pnsd', 'UPSTART_JOB': 'rc', 'PWD': '/', 'SUPERVISOR_GROUP_NAME': 'apnsd', 'RUNLE
VEL': '2', 'PATH': '/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
', 'runlevel': '2', 'previous': 'N'}
Do not show a modified python variable!
There is a bug in Supervisor; some variables (like those containing a /
) have to be quoted.
In that case, you need:
[program:apnsd]
command=/home/dotcloud/current/printenv.py
environment= PYTHONPATH="/home/dotcloud/current/apnsd/"
(The space in = PYTHONPATH
is not mandatory, it's just to make the file slightly more readable; the quotes around the value of PYTHONPATH
are, however, required!)
I will update dotCloud's documentation to mention this issue.