如何修复AWS Elastic beantalkd中的捆绑包错误

时间:2019-06-23 06:22:44

标签: ruby-on-rails amazon-elastic-beanstalk

我是菜鸟用户AWS Elastic beantalk,这是我在本地计算机上指定的应用程序

  • 红宝石:2.6.3p62
  • 捆绑包:2.0.2
  • 路轨:5.2.3
  • 彪马:3.12.1
$eb create


2019-06-23 06:17:18    INFO    Created CloudWatch alarm named: awseb-e-cpfnjrtvdk-stack-AWSEBCloudwatchAlarmLow-GYT3H9Y4NMZV
2019-06-23 06:17:25    ERROR   [Instance: i-028a561a32ccd0ce4] Command failed on instance. Return code: 1 Output: (TRUNCATED)...:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
    from /opt/rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0/rubygems.rb:308:in `activate_bin_path'
    from /opt/rubies/ruby-2.6.3/bin/bundle:23:in `<main>'.
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
2019-06-23 06:17:25    INFO    Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
2019-06-23 06:18:27    ERROR   Create environment operation is complete, but with errors. For more information, see troubleshooting documentation.

然后我尝试解决

# Go to your project root directory
$ mkdir .ebextensions
$ vim .ebextensions/bundler_install.config 

  files:
    "/tmp/45_nginx_https_rw.sh":
      owner: root
      group: root
      mode: "000644"
      content: |
        #! /bin/bash

        CONFIGURED=`grep -c "return 301 https" /opt/elasticbeanstalk/support/conf/webapp_healthd.conf`

        if [ $CONFIGURED = 0 ]
           then
             sed -i '/listen 80;/a \    if ($http_x_forwarded_proto = "http") { return 301 https://$host$request_uri; }\n' /opt/elasticbeanstalk/support/conf/webapp_healthd.conf
             logger -t nginx_rw "https rewrite rules added"
             exit 0
           else
             logger -t nginx_rw "https rewrite rules already set"
             exit 0
        fi

  container_commands:
    00_appdeploy_rewrite_hook:
     command: cp -v /tmp/45_nginx_https_rw.sh /opt/elasticbeanstalk/hooks/appdeploy/enact
    01_configdeploy_rewrite_hook:
      command: cp -v /tmp/45_nginx_https_rw.sh /opt/elasticbeanstalk/hooks/configdeploy/enact
    02_rewrite_hook_perms:
      command: chmod 755 /opt/elasticbeanstalk/hooks/appdeploy/enact/45_nginx_https_rw.sh /opt/elasticbeanstalk/hooks/configdeploy/enact/45_nginx_https_rw.sh
    03_rewrite_hook_ownership:
      command: chown root:users /opt/elasticbeanstalk/hooks/appdeploy/enact/45_nginx_https_rw.sh /opt/elasticbeanstalk/hooks/configdeploy/enact/45_nginx_https_rw.sh

然后我得到错误

ERROR   The configuration file .ebextensions/bundler_install.config in application version app-d78c-190624_064301 contains invalid YAML or JSON. YAML exception: Invalid Yaml: while parsing a block mapping
 in "<reader>", line 1, column 1:
    files:
    ^
expected <block end>, but found BlockMappingStart
 in "<reader>", line 21, column 3:
      container_commands:
      ^
, JSON exception: Invalid JSON: Unexpected character (f) at position 0.. Update the configuration file.

我希望所有事件都可以(INFO),但实际存在ara错误。如何在AWS beantalk中解决此问题?

1 个答案:

答案 0 :(得分:0)

此解决方法将其添加到文件“#在'./10_bundle_install.sh'之前运行:”'用`–

更改