3

http://docs.dotcloud.com/guides/daemons/状态:

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

但是,我发现我的 PYTHONPATH 环境变量没有被设置:

点云.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/

打印环境文件

#! /home/dotcloud/env/bin/python
import os
print "ENVIRONMENT"
print os.environ

日志:

    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'}

不要显示修改后的 python 变量!

4

1 回答 1

3

主管中有一个错误;/必须引用一些变量(例如包含 a 的变量)。

在这种情况下,您需要:

[program:apnsd]
command=/home/dotcloud/current/printenv.py
environment= PYTHONPATH="/home/dotcloud/current/apnsd/"

(in 中的空格= PYTHONPATH不是强制性的,只是为了使文件更具可读性;PYTHONPATH但是,值周围的引号是必需的!)

我将更新 dotCloud 的文档以提及此问题。

于 2012-05-18T16:31:16.043 回答