0

我有一个在Dotcloud上运行的 Django 应用程序。我已尝试添加Logentries日志记录,该日志记录在我的网站正常使用中有效,但导致我的 cron 作业因此错误而失败 -
Traceback (most recent call last): File "/home/dotcloud/current/my_project/manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/home/dotcloud/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line utility.execute() File "/home/dotcloud/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/dotcloud/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command commands = get_commands() File "/home/dotcloud/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 107, in get_commands apps = settings.INSTALLED_APPS File "/home/dotcloud/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 54, in __getattr__ self._setup(name) File "/home/dotcloud/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 50, in _setup self._configure_logging() File "/home/dotcloud/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 80, in _configure_logging logging_config_func(self.LOGGING) File "/usr/lib/python2.7/logging/config.py", line 777, in dictConfig dictConfigClass(config).configure() File "/usr/lib/python2.7/logging/config.py", line 575, in configure '%r: %s' % (name, e)) ValueError: Unable to configure handler 'logentries_handler': expected string or buffer

这是从 cron 运行的脚本之一 -

#!/bin/bash
echo "Loading definitions - check /var/log/supervisor/availsserver.log for results"
. /etc/profile
/home/dotcloud/env/bin/python /home/dotcloud/current/my_project/manage.py load_definitions

这些是我对 Logentries 的设置-
'logentries_handler': { 'token': os.getenv("LOGENTRIES_TOKEN"), 'class': 'logentries.LogentriesHandler' } .... 'logentries': { 'handlers': ['logentries_handler'], 'level': 'INFO', },

当我这样做时,LOGENTRIES_TOKEN 就在那里dotcloud env list

这是症状的摘要 -
- Logentries 日志记录在正常使用的站点中工作。
- 如果我手动运行脚本 -dotcloud run www ~/current/scripts/load_definitions.sh它可以工作。
- 如果我从我settings.py的 cron 作业中删除 Logentries 设置。
- 如果 Logentries 条目在我的settings.py

我花了几个小时试图找到解决方案。任何人都可以帮忙吗?

4

2 回答 2

0

您是否尝试过直接从~/environment.jsonor~/environment.yml而不是从导出的 shell 环境中读取值?

于 2014-03-26T20:40:48.947 回答
0

我已经解决了这个问题。
这是之前的 crontab -
0 13 * * * /home/dotcloud/current/scripts/load_definitions.sh 2>&1 | mail -s "Load definitions result" myemail@example.com.au
它不起作用。
这就是它现在的样子——
0 13 * * * /bin/bash -l -c '/home/dotcloud/current/scripts/load_definitions.sh' 2>&1 | mail -s "Load definitions result" myemail@example.com.au
它有效。添加/bin/bash -l -c修复它。也许有人可以告诉我为什么它没有按原来的方式工作?

于 2014-03-30T21:50:17.077 回答