Skip to content

Commit

Permalink
added play:precompile to build application before deploy:restart
Browse files Browse the repository at this point in the history
  • Loading branch information
Yamashita Yuu committed Feb 9, 2012
1 parent 4e8592a commit 9e0b8cd
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions conf/play-recipes.rb
Expand Up @@ -51,6 +51,7 @@
_cset :play_zip_url do _cset :play_zip_url do
"http://download.playframework.org/releases/#{File.basename(play_zip_file)}" "http://download.playframework.org/releases/#{File.basename(play_zip_file)}"
end end
_cset :play_preserve_zip, true
_cset :play_zip_file do _cset :play_zip_file do
File.join(shared_path, "play-#{play_version}.zip") File.join(shared_path, "play-#{play_version}.zip")
end end
Expand All @@ -60,8 +61,6 @@
_cset :play_cmd do _cset :play_cmd do
File.join(play_path, 'play') File.join(play_path, 'play')
end end
_cset :play_preserve_zip, true
_cset :play_modules, []
_cset :play_daemonize_method, :play _cset :play_daemonize_method, :play
_cset :play_daemon do _cset :play_daemon do
daemonize.__send__(play_daemonize_method) daemonize.__send__(play_daemonize_method)
Expand All @@ -76,17 +75,16 @@
transaction { transaction {
setup_ivy if fetch(:play_setup_ivy, false) setup_ivy if fetch(:play_setup_ivy, false)
install_play install_play
install_modules
} }
transaction { transaction {
play_daemon.setup play_daemon.setup
} }
end end


_cset :play_ivy_settings_template, File.join(File.dirname(__FILE__), 'templates', 'ivysettings.erb')
_cset :play_ivy_settings do _cset :play_ivy_settings do
File.join(capture('echo $HOME').chomp, '.ivy2', 'ivysettings.xml') File.join(capture('echo $HOME').chomp, '.ivy2', 'ivysettings.xml')
end end
_cset :play_ivy_settings_template, File.join(File.dirname(__FILE__), 'templates', 'ivysettings.erb')
task :setup_ivy, :roles => :app, :except => { :no_release => true } do task :setup_ivy, :roles => :app, :except => { :no_release => true } do
tempfile = File.join('/tmp', File.basename(play_ivy_settings)) tempfile = File.join('/tmp', File.basename(play_ivy_settings))
on_rollback { on_rollback {
Expand All @@ -100,15 +98,15 @@
end end


task :install_play, :roles => :app, :except => { :no_release => true } do task :install_play, :roles => :app, :except => { :no_release => true } do
temp_zip = File.join('/tmp', File.basename(play_zip_file))
temp_dir = File.join('/tmp', File.basename(play_zip_file, '.zip'))
on_rollback { on_rollback {
files = [ play_path ] files = [ play_path, temp_zip, temp_dir ]
files << play_zip_file unless play_preserve_zip files << play_zip_file unless play_preserve_zip
run "#{try_sudo} rm -rf #{files.join(' ')}" run "#{try_sudo} rm -rf #{files.join(' ')}"
} }
run "#{try_sudo} rm -f #{play_zip_file}" unless play_preserve_zip run "#{try_sudo} rm -f #{play_zip_file}" unless play_preserve_zip


temp_zip = File.join('/tmp', File.basename(play_zip_file))
temp_dir = File.join('/tmp', File.basename(play_zip_file, '.zip'))
run <<-E run <<-E
( test -f #{play_zip_file} || ( test -f #{play_zip_file} ||
( wget --no-verbose -O #{temp_zip} #{play_zip_url} && #{try_sudo} mv -f #{temp_zip} #{play_zip_file}; true ) ) && ( wget --no-verbose -O #{temp_zip} #{play_zip_url} && #{try_sudo} mv -f #{temp_zip} #{play_zip_file}; true ) ) &&
Expand All @@ -118,12 +116,6 @@
E E
run "#{try_sudo} rm -f #{play_zip_file}" unless play_preserve_zip run "#{try_sudo} rm -f #{play_zip_file}" unless play_preserve_zip
end end

task :install_modules, :roles => :app, :except => { :no_release => true } do
if 0 < play_modules.length
run "#{play_cmd} install #{play_modules.join(' ')}"
end
end
end end


namespace :daemonize do namespace :daemonize do
Expand Down Expand Up @@ -200,13 +192,18 @@


transaction { transaction {
dependencies dependencies
precompile if fetch(:play_use_precompile, true)
} }
end end


task :dependencies, :roles => :app, :except => { :no_release => true } do 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"
end end


task :precompile, :roles => :app, :except => { :no_release => true } do
run "cd #{release_path} && #{play_cmd} precompile"
end

desc "start play service" desc "start play service"
task :start, :roles => :app, :except => { :no_release => true } do task :start, :roles => :app, :except => { :no_release => true } do
play_daemon.start play_daemon.start
Expand Down

0 comments on commit 9e0b8cd

Please sign in to comment.