Closed dbclkclk closed 8 years ago
Hi, Looks like composer is trying to find the json file in pwd (which looks like /opt/codedeploy-agent). You can check the stdout of your script in: /opt/codedeploy-agent/deployment-root/deployment-group-id/deployment-id/logs/scripts.log
You can modify the script like this, which might solve the issue:
echo pwd cd path_to_composer_json sudo composer install sudo vendor/bin/phing www
@amartyag To try to * cd path_to_composer_json* , that's within my actually deploy directory. My question is, isn't the path /deployment-group-id/deployment-id/
, especially deployment-id generated dynamically? I dont want to have a case when on each deploy, a deployment-id folder is generated and I can't reference the correct composer.json file.
deployment-id is different for each deployment(as a unique id), it shows on the deployment page console too. Every time, a deployment-id folder will be generated, but your default directory will be /opt/codedeploy-agent/deployment-root/deployment-group-id/deployment-id, so actually just change to the relative directory inside your deployment archive will work.
@feverLu I dont think I get you. If this is being automated and I have a build.sh script that runs on each deploy, how do I know from my build.sh script what's the current named folder the project was deployed in (if this is something random)? Example:
#!/bin/bash
cd /deployment-root/deployment-group-[`[HOW DO I KNOW WHAT ID IT IS AT DEPLOY TIME WITHOUT FINDING THIS OUT FROM CONSOLE AND CHANGING THIS EVERY TIME`]/deployment-[`HOW DO I KNOW WHAT ID IT IS AT DEPLOY TIME WITHOUT FINDING THIS OUT FROM CONSOLE AND CHANGING THIS EVERY TIME`]
sudo composer install
sudo vendor/bin/phing www
Make sense?
Also please note, I mentioned this in my previous comment:
/deployment-[`HOW DO I KNOW WHAT ID IT IS AT DEPLOY TIME WITHOUT FINDING THIS OUT FROM CONSOLE AND CHANGING THIS EVERY TIME I DEPLOY`]
I guess this isn't possible
@dbclkclk This doesn't look like a bug, but rather a misconfiguration. Have a look at https://github.com/awslabs/aws-codedeploy-samples/ for examples.
If I were you, instead of trying to guess the directory, I would put my build script in a standard location and set the permissions of the file correctly before calling in in appspec.yml.
Your tree could look something like this:
deploy/
├── appspec.yml
├── deploy_hooks
│ └── build.sh
├── composer
├── composer.json
└── html
├── index.php
└── some_content
And appspec.yml should look like:
version: 0.0
os: linux
files:
- source: html/
destination: /var/www/html
- source: composer/
destination: /opt/composer
permissions:
- object: /var/www/html
owner: www-data
group: www-data
mode: 744
type:
- file
hooks:
BeforeInstall:
- location: deploy_hooks/build.sh
runas: root
Then point your build.sh to the location you moved the files to:
build.sh
#!/bin/bash
echo pwd
cd /opt/composer
composer install
vendor/bin/phing www
You can get the current deployment-id and deployment-group-id from the environment variables: https://blogs.aws.amazon.com/application-management/post/Tx1PX2XMPLYPULD/Using-CodeDeploy-Environment-Variables
You can use these to build up your absolute path.
Hi:
I'm trying to run composer in my before deployment to my httpd server. This is my configuration:
However, I'm getting this error:
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:98:in'
2016-06-07 22:37:31 INFO [codedeploy-agent(2469)]: Version file found in /opt/codedeploy- agent/.version.
2016-06-07 22:38:31 INFO [codedeploy-agent(2469)]: [Aws::CodeDeployCommand::Client 200 60.100514 0 retries] poll_host_command(host_identifier:"arn:aws:ec2:us-west-2:862883237080:instance/i-fa519821")
each' /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:98:in
block in execute' /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:168:increate_script_log_file_if_needed' /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:96:in
execute' /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:134:inblock (3 levels) in map' /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:125:in
each' /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:125:inblock (2 levels) in map' /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:63:in
execute_command' /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_poller.rb:132:inprocess_command' /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_poller.rb:65:in
perform' /opt/codedeploy-agent/lib/instance_agent/agent/base.rb:28:inrun' /opt/codedeploy-agent/lib/instance_agent/runner/child.rb:38:in
block in run' /opt/codedeploy-agent/lib/instance_agent/runner/child.rb:55:inwith_error_handling' /opt/codedeploy-agent/lib/instance_agent/runner/child.rb:37:in
run' /opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/child.rb:70:inblock in run_with_error_handling' /opt/codedeploy-agent/lib/instance_agent/runner/child.rb:55:in
with_error_handling' /opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/child.rb:69:inrun_with_error_handling' /opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/child.rb:33:in
block in start' /opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/child.rb:22:inloop' /opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/child.rb:22:in
start' /opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:202:inblock in spawn_child' /opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:200:in
fork' /opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:200:inspawn_child' /opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:192:in
block in spawn_children' /opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:191:intimes' /opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:191:in
spawn_children' /opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:134:instart' /opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:37:in
block in start' /opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:36:infork' /opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:36:in
start' /opt/codedeploy-agent/bin/codedeploy-agent:37:inblock (2 levels) in <main>' /opt/codedeploy-agent/vendor/gems/gli-2.5.6/lib/gli/command_support.rb:130:in
call' /opt/codedeploy-agent/vendor/gems/gli-2.5.6/lib/gli/command_support.rb:130:inexecute' /opt/codedeploy-agent/vendor/gems/gli-2.5.6/lib/gli/app_support.rb:262:in
block in call_command' /opt/codedeploy-agent/vendor/gems/gli-2.5.6/lib/gli/app_support.rb:275:incall' /opt/codedeploy-agent/vendor/gems/gli-2.5.6/lib/gli/app_support.rb:275:in
call_command' /opt/codedeploy-agent/vendor/gems/gli-2.5.6/lib/gli/app_support.rb:69:inrun' /opt/codedeploy-agent/bin/codedeploy-agent:84:in
This is my build.sh