Skip to content

Commit

Permalink
Supports *experimental* ey.yml option sync_assets
Browse files Browse the repository at this point in the history
When set to true, asset compilation will be executed on the primary
deployment server and rsync'd to other servers.

This feature is experimental.

It has been tested live but the current approach may not prove to be the
most effective way to speed up asset compilation. Future versions will
attempt to maintain a similar feature, but the implementation is subject
to change.
  • Loading branch information
martinemde committed Oct 16, 2014
1 parent a7a00db commit bb69736
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
4 changes: 3 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
## NEXT

* Supports `config.ref` in deploy hooks. Synonymous with `config.branch` but more correct because the `input_ref` is automatically resolved to a SHA before deploy.
* Add new ey.yml option `precompile_assets_command`
* Supports new ey.yml option `precompile_assets_command`
Setting `precompile_assets_command` overrides the asset precompile rake command. (default: `rake assets:precompile RAILS_GROUPS=assets`)
Bundler binstubs are in PATH so gem binaries will load through bundler.
* Supports new ey.yml option `experimental_sync_assets`
Setting to `true` will cause assets to be compiled once and rsync'd to other servers.

## v2.5.0 (2014-09-23)

Expand Down
6 changes: 4 additions & 2 deletions lib/engineyard-serverside/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ def fetch_deprecated(attr, replacement, default)
def_option :services_check_command, "which /usr/local/ey_resin/ruby/bin/ey-services-setup >/dev/null 2>&1"
def_option(:services_setup_command) { "/usr/local/ey_resin/ruby/bin/ey-services-setup #{app}" }

def_option :restart_groups, 1

DEFAULT_KEEP_RELEASES = 3

def_option :keep_releases, DEFAULT_KEEP_RELEASES
Expand All @@ -119,6 +117,10 @@ def fetch_deprecated(attr, replacement, default)
def_boolean_option :maintenance_on_migrate, true
def_boolean_option(:maintenance_on_restart) { required_downtime_stack? }

# experimental, need feedback from people using it, feature implementation subject to change or removal
def_option :restart_groups, 1
def_boolean_option :experimental_sync_assets, false

alias app_name app
alias environment framework_env # legacy because it would be nice to have less confusion around "environment"
alias migration_command migrate
Expand Down
2 changes: 1 addition & 1 deletion lib/engineyard-serverside/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def cached_deploy
setup_services
symlink_configs
setup_sqlite3_if_necessary
run_with_callbacks(:compile_assets) # defined in RailsAssetSupport
run_with_callbacks(:compile_assets)
enable_maintenance_page
run_with_callbacks(:migrate)
callback(:before_symlink)
Expand Down
14 changes: 13 additions & 1 deletion lib/engineyard-serverside/rails_assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,19 @@ def run_precompile_assets_task
asset_strategy.prepare do
cd = "cd #{paths.active_release}"
task = "PATH=#{paths.binstubs}:$PATH #{framework_envs} #{precompile_assets_command}"
runner.run "#{cd} && #{task}"

# This is a hack right now, but I haven't iterated over it enough for a good solution yet.
if config.experimental_sync_assets?
shell.status "Compiling assets once on localhost (experimental_sync_assets: true)"
shell.logged_system("sh -l -c '#{cd} && #{task}'")

shell.status "Syncing assets to other remote servers (experimental_sync_assets: true)"
runner.servers.remote.run_for_each do |server|
server.sync_directory_command(paths.public_assets)
end
else
runner.run "#{cd} && #{task}"
end
end
end

Expand Down

0 comments on commit bb69736

Please sign in to comment.