Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don’t worry, you can still create the pull request.
  • 9 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Commits on Mar 05, 2012
Yamashita Yuu added play:precompile_locally task to perform pre-compilation on loca…
…lhost
e24f90b
Yamashita Yuu display value from run_locally (stdout of commands), not just discarding 9c2bf37
Commits on Mar 06, 2012
Yamashita Yuu install play for deploy runner if needed 4760899
Commits on Mar 07, 2012
Yamashita Yuu fixed stupid syntax error of shell command. 326afe8
Yamashita Yuu added play_bin(_local)? to override acctual play command line.
expected usage is to set environment variables, like this:

    set :play_cmd do
      "env JAVA_HOME=/path/to/somewhere #{play_bin}"
    end
46ebf6e
Commits on Mar 12, 2012
Yamashita Yuu (1) changed play installation path; ${shared_path} -> ${shared_path}/…
…tools/play

(2) create parent directories of play installation path automatically
f007b30
Yamashita Yuu set JAVA_HOME to play command if play_java_home is set 66e9917
Yamashita Yuu ignore errors during backup of ivysettings.xml before performing conf…
…iguration
10b9d3b
Yamashita Yuu replaced File.absolute_path by File.expand_path to support Ruby 1.8.x ee150d4
Showing with 114 additions and 14 deletions.
  1. +2 −0 .gitignore
  2. +112 −14 conf/play-recipes.rb
View
2 .gitignore
@@ -9,3 +9,5 @@ lib
dist
*.pyc
*.pyo
+/play-*/
+/play-*.zip
View
126 conf/play-recipes.rb
@@ -53,14 +53,21 @@
end
_cset :play_preserve_zip, true
_cset :play_zip_file do
- File.join(shared_path, "play-#{play_version}.zip")
+ File.join(shared_path, 'tools', 'play', "play-#{play_version}.zip")
end
_cset :play_path do
- File.join(shared_path, "play-#{play_version}")
+ File.join(shared_path, 'tools', 'play', "play-#{play_version}")
end
- _cset :play_cmd do
+ _cset :play_bin do
File.join(play_path, 'play')
end
+ _cset :play_cmd do
+ if fetch(:play_java_home, nil)
+ "env JAVA_HOME=#{play_java_home} #{play_bin}"
+ else
+ play_bin
+ end
+ end
_cset :play_daemonize_method, :play
_cset :play_daemon do
daemonize.__send__(play_daemonize_method)
@@ -70,12 +77,34 @@
end
_cset :play_use_precompile, true # performe precompilation before restarting service if true
+ _cset :play_zip_file_local do
+ File.join(File.expand_path('.'), 'tools', 'play', "play-#{play_version}.zip")
+ end
+ _cset :play_path_local do
+ File.join(File.expand_path('.'), 'tools', 'play', "play-#{play_version}")
+ end
+ _cset :play_bin_local do
+ File.join(play_path_local, 'play')
+ end
+ _cset :play_cmd_local do
+ if fetch(:play_java_home_local, nil)
+ "env JAVA_HOME=#{play_java_home_local} #{play_bin_local}"
+ else
+ play_bin_local
+ end
+ end
+ _cset :play_precompile_locally, false # perform precompilation on localhost
+
namespace :setup do
desc "install play if needed"
task :default, :except => { :no_release => true } do
transaction {
setup_ivy if fetch(:play_setup_ivy, false)
install_play
+ if play_precompile_locally
+ setup_ivy_locally if fetch(:play_setup_ivy_locally, false)
+ install_play_locally
+ end
}
transaction {
play_daemon.setup
@@ -93,9 +122,23 @@
}
template = File.read(play_ivy_settings_template)
result = ERB.new(template).result(binding)
- run "test -d #{File.dirname(play_ivy_settings)} || mkdir -p #{File.dirname(play_ivy_settings)}"
+ run <<-E
+ ( test -d #{File.dirname(play_ivy_settings)} || mkdir -p #{File.dirname(play_ivy_settings)} ) &&
+ ( test -f #{play_ivy_settings} && mv -f #{play_ivy_settings} #{play_ivy_settings}.orig; true );
+ E
put result, tempfile
- run "diff #{tempfile} #{play_ivy_settings} || mv -f #{tempfile} #{play_ivy_settings}"
+ run "diff #{play_ivy_settings} #{tempfile} || mv -f #{tempfile} #{play_ivy_settings}"
+ end
+
+ _cset :play_ivy_settings_local, File.join(ENV['HOME'], '.ivy2', 'ivysettings.xml')
+ task :setup_ivy_locally, :except => { :no_release => true } do
+ template = File.read(play_ivy_settings_template)
+ result = ERB.new(template).result(binding)
+ logger.info(run_locally(<<-E))
+ ( test -d #{File.dirname(play_ivy_settings_local)} || mkdir -p #{File.dirname(play_ivy_settings_local)} ) &&
+ ( test -f #{play_ivy_settings_local} && mv -f #{play_ivy_settings_local} #{play_ivy_settings_local}.orig; true );
+ E
+ File.open(play_ivy_settings_local, 'w') { |fp| fp.write(result) }
end
task :install_play, :roles => :app, :except => { :no_release => true } do
@@ -108,15 +151,35 @@
}
run "#{try_sudo} rm -f #{play_zip_file}" unless play_preserve_zip
+ dirs = [ File.dirname(play_zip_file), File.dirname(play_path) ].uniq()
run <<-E
- ( test -f #{play_zip_file} ||
- ( wget --no-verbose -O #{temp_zip} #{play_zip_url} && #{try_sudo} mv -f #{temp_zip} #{play_zip_file}; true ) ) &&
- ( test -d #{play_path} ||
- ( unzip #{play_zip_file} -d /tmp && #{try_sudo} mv -f #{temp_dir} #{play_path}; true ) ) &&
- test -x #{play_cmd};
+ if ! test -x #{play_bin}; then
+ mkdir -p #{dirs.join(' ')} &&
+ ( test -f #{play_zip_file} || ( wget --no-verbose -O #{temp_zip} #{play_zip_url} && #{try_sudo} mv -f #{temp_zip} #{play_zip_file}; true ) ) &&
+ ( test -d #{play_path} || ( unzip -q #{play_zip_file} -d #{File.dirname(temp_dir)} && #{try_sudo} mv -f #{temp_dir} #{play_path}; true ) ) &&
+ test -x #{play_bin};
+ fi;
+ #{play_cmd} version;
E
run "#{try_sudo} rm -f #{play_zip_file}" unless play_preserve_zip
end
+
+ task :install_play_locally, :except => { :no_release => true } do # TODO: make install_play and install_play_locally together
+ on_rollback {
+ files = [ play_path_local, play_zip_file_local ]
+ logger.info(run_locally("rm -rf #{files.join(' ')}"))
+ }
+ dirs = [ File.dirname(play_zip_file_local), File.dirname(play_path_local) ].uniq()
+ logger.info(run_locally(<<-E))
+ if ! test -x #{play_bin_local}; then
+ mkdir -p #{dirs.join(' ')} &&
+ ( test -f #{play_zip_file_local} || ( wget --no-verbose -O #{play_zip_file_local} #{play_zip_url} ) ) &&
+ ( test -d #{play_path_local} || unzip -q #{play_zip_file_local} -d #{File.dirname(play_path_local)} ) &&
+ test -x #{play_bin_local};
+ fi;
+ #{play_cmd_local} version;
+ E
+ end
end
namespace :daemonize do
@@ -178,7 +241,7 @@
template = File.read(play_upstart_config_template)
result = ERB.new(template).result(binding)
put result, tempfile
- run "diff #{tempfile} #{play_upstart_config} || #{sudo} mv -f #{tempfile} #{play_upstart_config}"
+ run "diff #{play_upstart_config} #{tempfile} || #{sudo} mv -f #{tempfile} #{play_upstart_config}"
end
task :start, :roles => :app, :except => { :no_release => true } do
@@ -205,19 +268,54 @@
run "#{try_sudo} chmod g+w #{release_path}/tmp" if fetch(:group_writable, true)
transaction {
- dependencies
- precompile if play_use_precompile
+ if play_use_precompile
+ if play_precompile_locally
+ setup.setup_ivy_locally if fetch(:play_setup_ivy_locally, false)
+ setup.install_play_locally
+ dependencies_locally
+ precompile_locally
+ else
+ dependencies
+ precompile
+ end
+ else
+ dependencies
+ end
}
end
task :dependencies, :roles => :app, :except => { :no_release => true } do
- run "cd #{release_path} && #{play_cmd} dependencies --forProd"
+ run "cd #{release_path} && #{play_cmd} dependencies --forProd --sync"
+ end
+
+ task :dependencies_locally, :roles => :app, :except => { :no_release => true } do
+ logger.info(run_locally("#{play_cmd_local} dependencies --forProd --sync"))
+ run "mkdir -p #{release_path}/lib #{release_path}/modules"
+ find_servers_for_task(current_task).each { |server|
+ logger.info(run_locally(<<-E))
+ rsync -lrt --chmod=u+rwX,go+rX ./lib/ #{user}@#{server.host}:#{release_path}/lib/ &&
+ rsync -lrt --chmod=u+rwX,go+rX ./modules/ #{user}@#{server.host}:#{release_path}/modules/;
+ E
+ }
+ run "chmod -R g+w #{release_path}/lib #{release_path}/modules" if fetch(:group_writable, true)
end
task :precompile, :roles => :app, :except => { :no_release => true } do
run "cd #{release_path} && #{play_cmd} precompile"
end
+ task :precompile_locally, :roles => :app, :except => { :no_release => true } do
+ on_rollback {
+ logger.info(run_locally("#{play_cmd_local} clean"))
+ }
+ logger.info(run_locally("#{play_cmd_local} precompile"))
+ run "mkdir -p #{release_path}/precompiled"
+ find_servers_for_task(current_task).each { |server|
+ logger.info(run_locally("rsync -lrt --chmod=u+rwX,go+rX ./precompiled/ #{user}@#{server.host}:#{release_path}/precompiled/"))
+ }
+ run "chmod -R g+w #{release_path}/precompiled" if fetch(:group_writable, true)
+ end
+
desc "start play service"
task :start, :roles => :app, :except => { :no_release => true } do
play_daemon.start

No commit comments for this range

Something went wrong with that request. Please try again.