amazon-web-services - 如何为 Elastic Beanstalk 部署检索正常的 stdout/stderr 日志记录

标签 amazon-web-services amazon-elastic-beanstalk codeship

当我尝试 Elastic Beanstalk 部署时,我的 container_commands 之一可能会失败。不幸的是, Elastic Beanstalk 日志eb-commandprocessor.log只报告非零退出状态:
Error occurred during build: Command 08_collectstatic failed (Executor::NonZeroExitStatus)
其余的stdout/stderr由于 Unicode 字符,显然无法登录。 (由于 Unicode 引号等原因,我已经成功地解决了其他失败的命令)。我附上了下面的日志。

例如,做类似 ln -s Gruntfile.js Gruntfile.js 的事情会引发错误 ln: failed to create symbolic link ‘Gruntfile.js’: File exists .左角和右角引号是 Unicode 并且扰乱 Elastic Beanstalk 日志记录——显然。

我真的需要 stdout/stderr 的理智输出来解决容器命令失败中的潜在问题,但我不知道如何修补 EB 以记录此问题。 我怎样才能做到这一点?

.ebextensions/05_container_commands.config

option_settings:
  - namespace: aws:elasticbeanstalk:container:python:staticfiles
    option_name: /static/
    value: static/
  - namespace: aws:elasticbeanstalk:container:python
    option_name: WSGIPath
    value: wsgi.py
  - option_name: DJANGO_SETTINGS_MODULE
    value: settings

container_commands:
  08_collectstatic:
    command: "python manage.py collectstatic --noinput"



/var/log/eb-commandprocessor.log

-------------------------------------
/var/log/eb-commandprocessor.log
-------------------------------------
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 32: ordinal not in range(128)
Traceback (most recent call last):
  File "/usr/lib64/python2.6/logging/__init__.py", line 799, in emit
    stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 32: ordinal not in range(128)
Error occurred during build: Command 08_collectstatic failed (ElasticBeanstalk::ActivityFatalError)
	at /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/activity.rb:189:in `rescue in exec'
	...
caused by: command failed with error code 1: Traceback (most recent call last):
  File "/usr/lib64/python2.6/logging/__init__.py", line 799, in emit
    stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 32: ordinal not in range(128)
Traceback (most recent call last):
  File "/usr/lib64/python2.6/logging/__init__.py", line 799, in emit
    stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 32: ordinal not in range(128)
Traceback (most recent call last):
  File "/usr/lib64/python2.6/logging/__init__.py", line 799, in emit
    stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 32: ordinal not in range(128)
Traceback (most recent call last):
  File "/usr/lib64/python2.6/logging/__init__.py", line 799, in emit
    stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 32: ordinal not in range(128)
Traceback (most recent call last):
  File "/usr/lib64/python2.6/logging/__init__.py", line 799, in emit
    stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 32: ordinal not in range(128)
Error occurred during build: Command 08_collectstatic failed (Executor::NonZeroExitStatus)
	at /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/executor-1.0/lib/executor/exec.rb:81:in `sh'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/executor-1.0/lib/executor/exec.rb:24:in `sh'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/cfn-wrapper.rb:51:in `call_cfn_script'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/cfn-wrapper.rb:28:in `run_config_sets'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/infrahooks/infra-embeddedpostbuild.rb:20:in `execute!'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/executable.rb:56:in `instance_eval'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/executable.rb:56:in `execute!'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/command.rb:213:in `block (3 levels) in exec_stage'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/activity.rb:169:in `call'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/activity.rb:169:in `exec'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/activity.rb:126:in `timeout_exec'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/activity.rb:110:in `block in create'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/activity.rb:109:in `instance_eval'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/activity.rb:109:in `create'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/command.rb:209:in `block (2 levels) in exec_stage'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/command.rb:207:in `each'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/command.rb:207:in `each_with_index'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/command.rb:207:in `block in exec_stage'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/activity.rb:169:in `call'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/activity.rb:169:in `exec'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/activity.rb:126:in `timeout_exec'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/activity.rb:110:in `block in create'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/activity.rb:109:in `instance_eval'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/activity.rb:109:in `create'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/command.rb:204:in `exec_stage'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/command.rb:158:in `execute!'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/command.rb:68:in `run'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/command-processor.rb:64:in `block (2 levels) in execute!'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/activity.rb:169:in `call'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/activity.rb:169:in `exec'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/activity.rb:126:in `timeout_exec'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/activity.rb:110:in `block in create'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/activity.rb:109:in `instance_eval'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/activity.rb:109:in `create'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/command-processor.rb:62:in `block in execute!'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/command-processor.rb:106:in `execute_command'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/command-processor.rb:60:in `execute!'
	from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/bin/command-processor:46:in `<top (required)>'
	from /opt/elasticbeanstalk/lib/ruby/bin/command-processor:23:in `load'
	from /opt/elasticbeanstalk/lib/ruby/bin/command-processor:23:in `<main>'

最佳答案

您可以简单地将输出通过管道传输到日志文件并在部署期间对其进行跟踪:

commands:
  01-install-git:
    command: "yum install -y git &>> /tmp/deploy.log"
  02-install-nodejs-npm:
    command: "yum install -y --enablerepo=epel nodejs npm &>> /tmp/deploy.log"
  03-install-grunt:
    command: "npm install -g grunt-cli &>> /tmp/deploy.log"
  04-install-coffee:
    command: "npm install -g coffee-script &>> /tmp/deploy.log"
  05-install-bower:
    command: "npm install -g bower &>> /tmp/deploy.log"
container_commands:
  01_grunt:
    command: "export PATH=$PATH; grunt prod &>> /tmp/deploy.log"

关于amazon-web-services - 如何为 Elastic Beanstalk 部署检索正常的 stdout/stderr 日志记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28335811/

相关文章:

terraform - 在 terraform 变量中设置多行值

git - 部署时aws beanstalk 403错误

meteor + CodeShip + 模数

Redis 未加载到 Codeship 中

php - 将 IAM 角色与 PHP SDK 结合使用时出现问题

amazon-web-services - 如何在 S3 中列出前缀下的所有对象

amazon-web-services - 将文件上传到 S3 并将元数据上传到 RDS 的最佳实践?

amazon-web-services - 将 EC2 资源添加到 AWS Data Pipeline 时如何指定 EBS 卷?

python - AWS/EB - 受到内部虚拟连接的影响

node.js - 用于通过 Amazon 配置 CodeShip 的路径变量是什么?