From 541a63c7f7c567f01551333f3224cf082739dbe7 Mon Sep 17 00:00:00 2001 From: itsouvalas Date: Fri, 25 Aug 2017 12:33:02 +0000 Subject: [PATCH 1/7] added variable --- config/ey.yml | 178 +++++++++++++++++++ cookbooks/ey-custom/metadata.rb.old | 4 + cookbooks/ey-custom/recipes/after-restart.rb | 3 + deploy/after_restart.rb | 2 +- 4 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 config/ey.yml create mode 100644 cookbooks/ey-custom/metadata.rb.old create mode 100644 cookbooks/ey-custom/recipes/after-restart.rb diff --git a/config/ey.yml b/config/ey.yml new file mode 100644 index 0000000..8f575fd --- /dev/null +++ b/config/ey.yml @@ -0,0 +1,178 @@ +# Engine Yard Cloud Deploy Options +# +#################################################################### +# IMPORTANT +# Commit this file into your git repository. +# These options are loaded on the server during deploy. +#################################################################### +# +# Valid locations: +# * REPOSITORY_ROOT/config/ey.yml. +# * REPOSITORY_ROOT/ey.yml +# +# Further information available here: +# https://support.cloud.engineyard.com/entries/20996661-customize-your-deployment-on-engine-yard-cloud +# +# For advanced usage, see the source that loads this configuration: +# https://github.com/engineyard/engineyard-serverside/blob/master/lib/engineyard-serverside/configuration.rb +# +defaults: + # Run migrations during deploy by default. + # + # When set to true, runs the migration_command (below) during deploy. + # + # This setting can be overridden for individual deployments using + # the command line options --migrate or --no-migrate. + # + migrate: true + + # Default migration command to run when migrations are enabled. + # + migration_command: rake db:migrate --trace + + # Enables rails assets precompilation always and halts when the task fails. + # + # By default, assets are detected using app/assets and config/application.rb. + # + # If you use rails assets and you want Engine Yard to compile your assets + # during deploy, set this to true. If you want to compile assets locally + # before deploy, set this to false. Make sure you add `public/assets` to + # `.gitignore` if you want Engine Yard to precompile your assets. + # + # For more control over assets, set precompile_assets: false and + # run your precompile task in the deploy/before_compile_assets.rb deploy hook. + # + precompile_assets: true + + # Override the assets:precompile rake task. This option will be used instead + # of assets:precompile in the `rake assets:precompile` command. + # + #precompile_assets_task: assets:precompile + + # Asset strategies affect the way assets are stored on the server. + # + # * private + # Store assets directly in public/assets for each deployment. + # Previous assets are symlinked for continuity. + # When assets are reused, they are copied using rsync. + # + # * shifting + # Assets are kept in a shared directory on each server. + # When new assets are compiled, old assets are shifted to a shared + # last_assets directory. This has always been the default behavior. + # + # * shared + # Assets are kept in a shared directory on each server. + # When new assets are compiled, the same directory is used. + # Assets will accumulate in this mode if a cleaning script is not run. + # Use this strategy if you want to write your own asset cleaning script. + # + # * cleaning + # Like shared, but a cleaning script is run before each new compile. + # The script attempts to remove all files not mentioned by the old + # manifest.yml, before it is replaced by the new manifest (leaving 2 + # deployments worth of assets in the directory) + # + # "private" is recommended because it is the least error prone. + # If you prefer faster compilation, "shared" can be quicker, but will require + # custom scripting and will cause problems when rollbacks are used. + # "shifting" is the default behavior. + # + #asset_strategy: private + + # This list of repository relative paths is checked for changes during + # each deployment (when change detection is not disabled). If `git diff` + # detects changes since the last deployment, fresh assets will be compiled. + # + # This option overrides the default list, so include the following + # defaults if you need them. + # + #asset_dependencies: + #- app/assets # default + #- lib/assets # default + #- vendor/assets # default + #- Gemfile.lock # default + #- config/application.rb # default + #- config/routes.rb # default + #- config/requirejs.yml # example of a custom asset dependency + + # When true, precompiles assets even if no changes would be detected by + # running git diff with the asset_dependencies above. + # + # Default is false (always check git diff before asset compilation) + # + #precompile_unchanged_assets: false + + # Choose which servers should compile assets. + # + # Default behavior is to exclude util instances. + # Specify :all to compile on all servers including util servers. + # + #asset_roles: :all + + # Bundle without different bundler groups: + # Ex: bundle install --without '[bundle_without]' + # + # Default is "". + # Leave blank to remove --without from the bundle install command. + # + #bundle_without: + + # Add extra options to the bundle install command line. + # Does not override bundle_without, if specified. + # + # If the application's gems are vendored in the + # repository, setting --local can speed up bundle. + # + #bundle_options: + + # Enable maintenance page during migrate action (default) + # Setting this to false, disables maintenance page during migrations. + # + # CAUTION! No-downtime migrations requires careful migration + # planning. Migrations must be non-destructive. The *previous* + # deployment might serve pages during a partially migrated state. + # For example, if you rename a column, all traffic served during + # that migration will be broken until the new code is deployed. + # + #maintenance_on_migrate: true + + # Enable maintanence page during every deploy. + # Unicorn and Passenger support no-downtime deploys, so the default + # for these servers is false. Mongrel and some other servers default + # to true to avoid downtime during server restarting. + # + #maintenance_on_restart: + + # If true, always run deployments in verbose mode. + # + #verbose: false + + # Hide the warning shown when the Gemfile does not contain a recognized + # database adapter (mongodb for example) + # + # This warning is here to help new customers that accidentally have no adapter. + # You may safely set this to true if you aren't using a common database. + # + #ignore_database_adapter_warning: false + + # You can add custom keys that will be available in your deploy hooks. + # Custom keys will be available using config.key or config[:key] + # + #your_own_custom_key: custom info + + +#################################################################### +# Environment specific options. +# +# The options you specify here will only apply to a single environment +# that exactly matches the environment name key. +# +# Environment options will override the default options above. +# +environments: + + # These options will only apply to the EXAMPLE_ENVIRONMENT environment. + #EXAMPLE_ENVIRONMENT: + #precompile_unchanged_assets: true + diff --git a/cookbooks/ey-custom/metadata.rb.old b/cookbooks/ey-custom/metadata.rb.old new file mode 100644 index 0000000..6a87fbf --- /dev/null +++ b/cookbooks/ey-custom/metadata.rb.old @@ -0,0 +1,4 @@ +name 'ey-custom' + +depends 'custom-rails_secrets' +depends 'after-restart' diff --git a/cookbooks/ey-custom/recipes/after-restart.rb b/cookbooks/ey-custom/recipes/after-restart.rb new file mode 100644 index 0000000..1d26641 --- /dev/null +++ b/cookbooks/ey-custom/recipes/after-restart.rb @@ -0,0 +1,3 @@ +on_app_master do + run "bundle exec rake db:load_sample_if_empty_db DISABLE_DATABASE_ENVIRONMENT_CHECK=1" +end diff --git a/deploy/after_restart.rb b/deploy/after_restart.rb index e982a85..518f8be 100644 --- a/deploy/after_restart.rb +++ b/deploy/after_restart.rb @@ -1,3 +1,3 @@ on_app_master do run "bundle exec rake db:load_sample_if_empty_db" -end \ No newline at end of file +end From 1d9010318dd167bb1989e066703227670976673c Mon Sep 17 00:00:00 2001 From: itsouvalas Date: Fri, 25 Aug 2017 12:37:58 +0000 Subject: [PATCH 2/7] added variable on deploy --- deploy/after_restart.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/after_restart.rb b/deploy/after_restart.rb index 518f8be..1d26641 100644 --- a/deploy/after_restart.rb +++ b/deploy/after_restart.rb @@ -1,3 +1,3 @@ on_app_master do - run "bundle exec rake db:load_sample_if_empty_db" + run "bundle exec rake db:load_sample_if_empty_db DISABLE_DATABASE_ENVIRONMENT_CHECK=1" end From 7f1990851578e223760b9351fd78599a52cb2be8 Mon Sep 17 00:00:00 2001 From: itsouvalas Date: Fri, 25 Aug 2017 12:59:38 +0000 Subject: [PATCH 3/7] killed connections --- deploy/after_restart.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/deploy/after_restart.rb b/deploy/after_restart.rb index 1d26641..afc57c3 100644 --- a/deploy/after_restart.rb +++ b/deploy/after_restart.rb @@ -1,3 +1,4 @@ on_app_master do + run 'echo "SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname=\'database_name\';" | psql -U postgres' run "bundle exec rake db:load_sample_if_empty_db DISABLE_DATABASE_ENVIRONMENT_CHECK=1" end From acca3617b18ab9103417d76a51a62d940a04499b Mon Sep 17 00:00:00 2001 From: itsouvalas Date: Fri, 25 Aug 2017 13:10:36 +0000 Subject: [PATCH 4/7] killed connections --- deploy/after_restart.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/after_restart.rb b/deploy/after_restart.rb index afc57c3..0c38138 100644 --- a/deploy/after_restart.rb +++ b/deploy/after_restart.rb @@ -1,4 +1,4 @@ on_app_master do - run 'echo "SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname=\'database_name\';" | psql -U postgres' + run 'echo "SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname=\'spina_sample_app\';" | psql -U postgres' run "bundle exec rake db:load_sample_if_empty_db DISABLE_DATABASE_ENVIRONMENT_CHECK=1" end From 8b9cecba8fc1328e9efdf91350a2a1d207c6b6a1 Mon Sep 17 00:00:00 2001 From: itsouvalas Date: Fri, 25 Aug 2017 14:29:11 +0000 Subject: [PATCH 5/7] killed connections --- deploy/after_restart.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/after_restart.rb b/deploy/after_restart.rb index 0c38138..4e3d211 100644 --- a/deploy/after_restart.rb +++ b/deploy/after_restart.rb @@ -1,4 +1,4 @@ on_app_master do - run 'echo "SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname=\'spina_sample_app\';" | psql -U postgres' + run "echo "SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname='spina_sample_app';" | psql -U postgres" run "bundle exec rake db:load_sample_if_empty_db DISABLE_DATABASE_ENVIRONMENT_CHECK=1" end From 42ef30805a4e6785b34827ee48cbeebf6afad6f8 Mon Sep 17 00:00:00 2001 From: itsouvalas Date: Fri, 25 Aug 2017 14:31:28 +0000 Subject: [PATCH 6/7] killed connections --- deploy/after_restart.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/after_restart.rb b/deploy/after_restart.rb index 4e3d211..d2ffc41 100644 --- a/deploy/after_restart.rb +++ b/deploy/after_restart.rb @@ -1,4 +1,4 @@ on_app_master do - run "echo "SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname='spina_sample_app';" | psql -U postgres" + run "echo \"SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname='spina_sample_app';\" | psql -U postgres" run "bundle exec rake db:load_sample_if_empty_db DISABLE_DATABASE_ENVIRONMENT_CHECK=1" end From bb4d72d227cf726efb3419fa48242e6f14909601 Mon Sep 17 00:00:00 2001 From: itsouvalas Date: Mon, 28 Aug 2017 14:26:09 +0000 Subject: [PATCH 7/7] removed after restart.rb --- .../recipes/templates/secrets.yml.SpinaSampleApp.erb | 2 ++ .../recipes/templates/secrets.yml.spina.erb | 2 ++ .../recipes/templates/secrets.yml.spina_sample_app.erb | 2 ++ deploy/after_restart.rb | 4 ---- 4 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 cookbooks/custom-rails_secrets/recipes/templates/secrets.yml.SpinaSampleApp.erb create mode 100644 cookbooks/custom-rails_secrets/recipes/templates/secrets.yml.spina.erb create mode 100644 cookbooks/custom-rails_secrets/recipes/templates/secrets.yml.spina_sample_app.erb delete mode 100644 deploy/after_restart.rb diff --git a/cookbooks/custom-rails_secrets/recipes/templates/secrets.yml.SpinaSampleApp.erb b/cookbooks/custom-rails_secrets/recipes/templates/secrets.yml.SpinaSampleApp.erb new file mode 100644 index 0000000..7f474a4 --- /dev/null +++ b/cookbooks/custom-rails_secrets/recipes/templates/secrets.yml.SpinaSampleApp.erb @@ -0,0 +1,2 @@ +production: + secret_key_base: ae6b65c0d18b3f9c070f4ddf8ff33d8e12eb23ff91b3905137bd0a6c9184cf73a7c4d556c253dce149598841cc50678c59c6a840b8ba7ecadcad1e4c0d33ec48 diff --git a/cookbooks/custom-rails_secrets/recipes/templates/secrets.yml.spina.erb b/cookbooks/custom-rails_secrets/recipes/templates/secrets.yml.spina.erb new file mode 100644 index 0000000..7f474a4 --- /dev/null +++ b/cookbooks/custom-rails_secrets/recipes/templates/secrets.yml.spina.erb @@ -0,0 +1,2 @@ +production: + secret_key_base: ae6b65c0d18b3f9c070f4ddf8ff33d8e12eb23ff91b3905137bd0a6c9184cf73a7c4d556c253dce149598841cc50678c59c6a840b8ba7ecadcad1e4c0d33ec48 diff --git a/cookbooks/custom-rails_secrets/recipes/templates/secrets.yml.spina_sample_app.erb b/cookbooks/custom-rails_secrets/recipes/templates/secrets.yml.spina_sample_app.erb new file mode 100644 index 0000000..7f474a4 --- /dev/null +++ b/cookbooks/custom-rails_secrets/recipes/templates/secrets.yml.spina_sample_app.erb @@ -0,0 +1,2 @@ +production: + secret_key_base: ae6b65c0d18b3f9c070f4ddf8ff33d8e12eb23ff91b3905137bd0a6c9184cf73a7c4d556c253dce149598841cc50678c59c6a840b8ba7ecadcad1e4c0d33ec48 diff --git a/deploy/after_restart.rb b/deploy/after_restart.rb deleted file mode 100644 index d2ffc41..0000000 --- a/deploy/after_restart.rb +++ /dev/null @@ -1,4 +0,0 @@ -on_app_master do - run "echo \"SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname='spina_sample_app';\" | psql -U postgres" - run "bundle exec rake db:load_sample_if_empty_db DISABLE_DATABASE_ENVIRONMENT_CHECK=1" -end