dimanche 26 juillet 2015

AWS OpsWorks - Cannot deploy my application with AWS OpsWorks, especially cannot succeed in migration

Following this document(http://ift.tt/1JDUiv2), I'm trying to deploy my rails application with AWS OpsWorks. However, I failed to do, especially when I tried to migrate it.

This is error log.

Your bundle is complete!
Gems in the groups test and development were not installed.
It was installed into /home/deploy/.bundler/sample_app

[2015-07-26T08:21:32+00:00] INFO: No database adapter specified for sample_app, guessing
[2015-07-26T08:21:32+00:00] INFO: Looks like sample_app uses mysql2 in its Gemfile
[2015-07-26T08:21:32+00:00] INFO: Processing template[/srv/www/sample_app/shared/config/database.yml] action create (/var/lib/aws/opsworks/cache.stage2/cookbooks/deploy/definitions/opsworks_deploy.rb line 115)
[2015-07-26T08:21:32+00:00] INFO: deploy[/srv/www/sample_app] queueing checkdeploy hook /srv/www/sample_app/releases/20150726082129/deploy/before_migrate.rb
[2015-07-26T08:21:32+00:00] INFO: Processing template[/srv/www/sample_app/shared/config/database.yml] action create (/var/lib/aws/opsworks/cache.stage2/cookbooks/deploy/definitions/opsworks_deploy.rb line 115)
[2015-07-26T08:21:32+00:00] INFO: deploy[/srv/www/sample_app] made pre-migration symlinks
[2015-07-26T08:21:32+00:00] INFO: deploy[/srv/www/sample_app] set user to deploy
[2015-07-26T08:21:32+00:00] INFO: deploy[/srv/www/sample_app] set group to nginx
[2015-07-26T08:21:32+00:00] INFO: deploy[/srv/www/sample_app] migrating deploy

================================================================================
Error executing action `deploy` on resource 'deploy[/srv/www/sample_app]'
================================================================================


Chef::Exceptions::Exec
----------------------
if [ -f Gemfile ]; then echo 'OpsWorks: Gemfile found - running migration with bundle exec' && /usr/local/bin/bundle exec /usr/local/bin/rake db:migrate; else echo 'OpsWorks: no Gemfile - running plain migrations' && /usr/local/bin/rake db:migrate; fi returned 1, expected 0


Cookbook Trace:
---------------
/var/lib/aws/opsworks/cache.stage2/cookbooks/opsworks_commons/libraries/monkey_patch_deploy_provider.rb:45:in `block in migrate'
/var/lib/aws/opsworks/cache.stage2/cookbooks/opsworks_commons/libraries/monkey_patch_deploy_provider.rb:39:in `migrate'


Resource Declaration:
---------------------
# In /var/lib/aws/opsworks/cache.stage2/cookbooks/deploy/definitions/opsworks_deploy.rb

65:     deploy deploy[:deploy_to] do
66:       provider Chef::Provider::Deploy.const_get(deploy[:chef_provider])
67:       keep_releases deploy[:keep_releases]
68:       repository deploy[:scm][:repository]
69:       user deploy[:user]
70:       group deploy[:group]
71:       revision deploy[:scm][:revision]
72:       migrate deploy[:migrate]
73:       migration_command deploy[:migrate_command]
74:       environment deploy[:environment].to_hash
75:       purge_before_symlink(deploy[:purge_before_symlink]) unless deploy[:purge_before_symlink].nil?
76:       create_dirs_before_symlink(deploy[:create_dirs_before_symlink])
77:       symlink_before_migrate(deploy[:symlink_before_migrate])
78:       symlinks(deploy[:symlinks]) unless deploy[:symlinks].nil?
79:       action deploy[:action]
80: 
81:       if deploy[:application_type] == 'rails' && node[:opsworks][:instance][:layers].include?('rails-app')
82:         restart_command "sleep #{deploy[:sleep_before_restart]} && #{node[:opsworks][:rails_stack][:restart_command]}"
83:       end
84: 



Compiled Resource:
------------------
# Declared in /var/lib/aws/opsworks/cache.stage2/cookbooks/deploy/definitions/opsworks_deploy.rb:65:in `block in from_file'

deploy("/srv/www/sample_app") do
params {:deploy_data=>{"deploy_to"=>"/srv/www/sample_app", "chef_provider"=>"Timestamped", "keep_releases"=>5, "current_path"=>"/srv/www/sample_app/current", "document_root"=>"public", "ignore_bundler_groups"=>["test", "development"], "absolute_document_root"=>"/srv/www/sample_app/current/public/", "rake"=>"/usr/local/bin/rake", "migrate"=>true, "migrate_command"=>"if [ -f Gemfile ]; then echo 'OpsWorks: Gemfile found - running migration with bundle exec' && /usr/local/bin/bundle exec /usr/local/bin/rake db:migrate; else echo 'OpsWorks: no Gemfile - running plain migrations' && /usr/local/bin/rake db:migrate; fi", "rails_env"=>"production", "action"=>"deploy", "user"=>"deploy", "group"=>"nginx", "shell"=>"/bin/bash", "home"=>"/home/deploy", "sleep_before_restart"=>0, "stack"=>{"needs_reload"=>true}, "enable_submodules"=>true, "shallow_clone"=>false, "delete_cached_copy"=>true, "purge_before_symlink"=>["log", "tmp/pids", "public/system"], "create_dirs_before_symlink"=>["tmp", "public", "config"], "symlink_before_migrate"=>{"config/database.yml"=>"config/database.yml", "config/memcached.yml"=>"config/memcached.yml"}, "symlinks"=>{"system"=>"public/system", "pids"=>"tmp/pids", "log"=>"log"}, "environment"=>{"RAILS_ENV"=>"production", "RUBYOPT"=>"", "RACK_ENV"=>"production", "HOME"=>"/home/deploy", "SECRET_KEY_BASE"=>"42426faeafcbeafc1ac73a23d0844b7e3f4a27d8cc5a15b8c9ea9e092bab7f0d2f87c5102411aac919a3425bbe4560fb686e22525871236b9322c4b5573bf4da"}, "environment_variables"=>{"SECRET_KEY_BASE"=>"42426faeafcbeafc1ac73a23d0844b7e3f4a27d8cc5a15b8c9ea9e092bab7f0d2f87c5102411aac919a3425bbe4560fb686e22525871236b9322c4b5573bf4da"}, "ssl_support"=>false, "auto_npm_install_on_deploy"=>true, "nodejs"=>{"restart_command"=>"monit restart node_web_app_sample_app", "stop_command"=>"monit stop node_web_app_sample_app", "port"=>80}, "application"=>"sample_app", "application_type"=>"rails", "auto_bundle_on_deploy"=>true, "deploying_user"=>"arn:aws:iam::934616152548:root", "domains"=>["sample_app"], "mounted_at"=>nil, "restart_command"=>nil, "ssl_certificate"=>nil, "ssl_certificate_key"=>nil, "ssl_certificate_ca"=>nil, "scm"=>{"scm_type"=>"git", "repository"=>"http://ift.tt/1JGRGce", "revision"=>nil, "ssh_key"=>nil, "user"=>nil, "password"=>nil}, "database"=>{"host"=>"172.31.10.7", "database"=>"sample_app", "port"=>3306, "username"=>"root", "password"=>"k7gs5opqfr", "reconnect"=>true, "data_source_provider"=>"stack", "type"=>"mysql"}, "memcached"=>{"host"=>nil, "port"=>11211}}, :app=>"sample_app", :name=>nil}
provider Chef::Provider::Deploy::Timestamped
action [:deploy]
updated true
updated_by_last_action true
retries 0
retry_delay 2
deploy_to "/srv/www/sample_app"
environment {"RAILS_ENV"=>"production", "RUBYOPT"=>"", "RACK_ENV"=>"production", "HOME"=>"/home/deploy", "SECRET_KEY_BASE"=>"42426faeafcbeafc1ac73a23d0844b7e3f4a27d8cc5a15b8c9ea9e092bab7f0d2f87c5102411aac919a3425bbe4560fb686e22525871236b9322c4b5573bf4da", "LC_ALL"=>"C"}
repository_cache "cached-copy"
purge_before_symlink ["log", "tmp/pids", "public/system"]
create_dirs_before_symlink ["tmp", "public", "config"]
symlink_before_migrate {"config/database.yml"=>"config/database.yml", "config/memcached.yml"=>"config/memcached.yml"}
symlinks {"system"=>"public/system", "pids"=>"tmp/pids", "log"=>"log"}
revision "HEAD"
migrate true
remote "origin"
enable_submodules true
scm_provider Chef::Provider::Git
keep_releases 5
enable_checkout true
checkout_branch "deploy"
cookbook_name "deploy"
recipe_name "rails"
repo "http://ift.tt/1JGRGce"
user "deploy"
group "nginx"
migration_command "if [ -f Gemfile ]; then echo 'OpsWorks: Gemfile found - running migration with bundle exec' && /usr/local/bin/bundle exec /usr/local/bin/rake db:migrate; else echo 'OpsWorks: no Gemfile - running plain migrations' && /usr/local/bin/rake db:migrate; fi"
restart_command "sleep 0 && ../../shared/scripts/unicorn clean-restart"
before_migrate #<Proc:0x007f2d074dcbb0@/var/lib/aws/opsworks/cache.stage2/cookbooks/deploy/definitions/opsworks_deploy.rb:100>
shared_path "/srv/www/sample_app/shared"
destination "/srv/www/sample_app/shared/cached-copy"
current_path "/srv/www/sample_app/current"
end



[2015-07-26T08:21:33+00:00] INFO: Running queued delayed notifications before re-raising exception
[2015-07-26T08:21:33+00:00] ERROR: Running exception handlers
[2015-07-26T08:21:33+00:00] ERROR: Exception handlers complete
[2015-07-26T08:21:33+00:00] FATAL: Stacktrace dumped to /var/lib/aws/opsworks/cache.stage2/chef-stacktrace.out
[2015-07-26T08:21:33+00:00] ERROR: deploy[/srv/www/sample_app] (deploy::rails line 65) had an error: Chef::Exceptions::Exec: if [ -f Gemfile ]; then echo 'OpsWorks: Gemfile found - running migration with bundle exec' && /usr/local/bin/bundle exec /usr/local/bin/rake db:migrate; else echo 'OpsWorks: no Gemfile - running plain migrations' && /usr/local/bin/rake db:migrate; fi returned 1, expected 0
[2015-07-26T08:21:33+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

It seems that it succeeded in "bundle install".

With ssh, I went to /srv/www/sample_app/releases/20150726082129 and typed

rake db:migrate

then error sentences appeared like this.

Could not find i18n-0.7.0 in any of the sources
Run `bundle install` to install missing gems.

Next, following this error sentences, I typed

sudo bundle install

then it says

Your bundle is complete!
Gems in the groups test and development were not installed.
It was installed into /home/deploy/.bundler/sample_app

however, it appears that gem is empty. If I typed

gem list

I cannot find gems specified in Gemfile

bigdecimal (1.2.6)
bundler (1.5.3)
io-console (0.4.3)
json (1.8.1)
kgio (2.9.3)
minitest (5.4.3)
power_assert (0.2.2)
psych (2.0.8)
rack (1.6.4)
raindrops (0.15.0)
rake (10.4.2)
rdoc (4.2.0)
test-unit (3.0.8)
unicorn (4.7.0)

I think these are hints to solve my problem.

I'm sorry that I'm not good at English so much, so if you cannot understand what I wanted you to help, please tell me unknown point.




1 commentaire: