AWS CodeDeploy和Ruby App

时间:2018-05-25 14:37:31

标签: ruby-on-rails amazon-web-services aws-code-deploy

我有一个ruby应用程序,我可以手动安装或更新脚本。但是当我试图通过codeDeploy这样做时,我得到了各种各样的错误。

  1. 无法通过权限块
  2. 查看权限
  3. 安装后脚本即使我可以手动运行也无法执行
  4. 以下是appspec.yml

    version: 0.0
    os: linux
    files:
      - source: /
        destination: /var/www/dev
    permissions:
      - object: /var/www/dev/
        owner: ubuntu
        group: ubuntu
        mode: 777
        type: 
          - directory
    hooks:
      AfterInstall:
        - location: deploy/update.sh
          timeout: 240
      ApplicationStart:
        - location: deploy/restart.sh
    timeout: 120
    

    我得到的错误低于

    2018-05-25 14:26:53 INFO  [codedeploy-agent(10260)]: Version file found in /opt/codedeploy-agent/.version with agent version OFFICIAL_1.0-1.1458_deb.
    2018-05-25 14:26:53 INFO  [codedeploy-agent(10260)]: [Aws::CodeDeployCommand::Client 200 0.191732 0 retries] put_host_command_complete(command_status:"Failed",diagnostics:{format:"JSON",payload:#<String "{\"error_code\":4,\"script_name\":\"deploy/update.sh\",\"message\":\"Script at specified location: deploy/update.sh failed with exit code 127\",\"log\":\"[stderr]and the repository exists.\\n[stdout]cfc1321eebed87a74291f5483be49a0c59faa99f\\n[stdout]884ddd1f100b0853e595a30d81020e4d8d8a85b5\\n[stdout]cfc1321eebed87a74291f5483be49a0c59faa99f\\n[stdout]Need to pull\\n[stderr]Host key verification failed.\\r\\n[stderr]fatal: Could not read from remote repository.\\n[stderr]\\n[stderr]Please make sure you have the correct access rights\\n[stderr]and the repository exists.\\n[stderr]/opt/codedeploy-agent/deployment-root/4ebdb723-707c-4cc8-b714-c02d10c80c75/d-6291XRDYS/deployment-archive/deploy/update.sh: line 21: bundle: command not found\\n[stderr]rake aborted!\\n[stderr]LoadError: cannot load such file -- bundler/setup\\n[stderr]/var/www/dev/config/boot.rb:3:in `<top (required)>'\\n[stderr]/var/www/dev/config/application.rb:3:in `require_relative'\\n[stderr]/var/www/dev//config/application.rb:3:in " ... (2302 bytes)>},host_command_identifier:"WyJjb20uYW1hem9uLmFwb2xsby5kZXBsb3ljb250cm9sLmRvbWFpbi5Ib3N0Q29tbWFuZElkZW50aWZpZXIiLHsiZGVwbG95bWVudElkIjoiQ29kZURlcGxveS9hcC1zb3V0aGVhc3QtMi9Qcm9kL2Fybjphd3M6c2RzOmFwLXNvdXRoZWFzdC0yOjE4MjMyNTAzODA4OTpkZXBsb3ltZW50L2QtNjI5MVhSRFlTIiwiaG9zdElkIjoiYXJuOmF3czplYzI6YXAtc291dGhlYXN0LTI6MTgyMzI1MDM4MDg5Omluc3RhbmNlL2ktMGY3ZDlmZTRlMjQwYmM1YmUiLCJjb21tYW5kTmFtZSI6IkFmdGVySW5zdGFsbCIsImNvbW1hbmRQb3NpdGlvbiI6NSwiY29tbWFuZEF0dGVtcHQiOjF9XQ==")
    
    2018-05-25 14:26:53 ERROR [codedeploy-agent(10260)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Error during perform: InstanceAgent::Plugins::CodeDeployPlugin::ScriptError - Script at specified location: deploy/update.sh failed with exit code 127 - /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:173:in `execute_script'
    /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:128:in `block (2 levels) in execute'
    /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:116:in `each'
    /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:116:in `block in execute'
    /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:198:in `create_script_log_file_if_needed'
    /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:114:in `execute'
    /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:158:in `block (3 levels) in map'
    /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:146:in `each'
    /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:146:in `block (2 levels) in map'
    /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:68:in `execute_command'
    /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_poller.rb:143:in `process_command'
    /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_poller.rb:76:in `block in perform'
    /opt/codedeploy-agent/vendor/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:348:in `run_task'
    /opt/codedeploy-agent/vendor/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:337:in `block (3 levels) in create_worker'
    /opt/codedeploy-agent/vendor/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:320:in `loop'
    /opt/codedeploy-agent/vendor/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:320:in `block (2 levels) in create_worker'
    /opt/codedeploy-agent/vendor/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:319:in `catch'
    /opt/codedeploy-agent/vendor/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:319:in `block in create_worker'
    /opt/codedeploy-agent/vendor/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `block in create_with_logging_context'
    

    任何帮助解决它都会非常有帮助。

1 个答案:

答案 0 :(得分:0)

问题在于解决方案。我也在脚本中进行git pull,这在执行期间引起冲突,因为AWS CodeDeploy在开始执行时也会复制代码。

一旦我从脚本中删除了git pull命令,它就会再次开始工作。

CodeDeploy中的错误处理/报告需要改进