Приложение AWS CodeDeploy и Ruby - PullRequest
0 голосов
/ 25 мая 2018

У меня есть приложение ruby, которое я могу установить или обновить с помощью сценариев вручную.Но когда я пытаюсь сделать это с помощью codeDeploy, я получаю всевозможные ошибки.

  1. Невозможно изменить разрешения с помощью блока разрешений
  2. После того, как скрипт установки просто не запускается, хотя я могу запустить его вручную

Нижеthe 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 голосов
/ 24 июля 2018

Проблема была на подходе.Я также выполнял git pull в сценарии, что вызывало конфликт во время выполнения, так как AWS CodeDeploy также копировал код при запуске.

Как только я удалил команду git pull из скрипта, она снова заработала.

Обработка ошибок и отчетность в CodeDeploy нуждается в улучшении

...