forked from comunes/kune
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcapistrano-example.rb
74 lines (51 loc) · 2.63 KB
/
capistrano-example.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
set :application, "kune"
set :repository, "https://git.gitorious.org/kune/p2pvalue-trunk.git"
set :scm, :git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
set :db_pwd, 'db4kune'
set :use_sudo, false
role :web, "your web-server here" # Your HTTP server, Apache/etc
role :app, "your app-server here" # This may be the same as your `Web` server
role :db, "your primary db-server here", :primary => true # This is where Rails migrations will run
role :db, "your slave db-server here"
# if you want to clean up old releases on each deploy uncomment this:
after "deploy:restart", "deploy:cleanup"
namespace :deploy do
task :finalize_update do
# Change database password
db_files = %w{pom.xml bin/liquibase-migrate.sh bin/liquibase-rollback.sh bin/i18n-db2gwt.sh src/main/resources/db/liquibase.properties src/main/resources/META-INF/persistence.xml}.map{ |f| "#{ release_path }/#{ f }" }.join(" ")
run "sed -i 's/db4kune/#{ db_pwd }/g' #{ db_files }"
run "cd #{ release_path } && mvn assembly:assembly -P production -Dliquibase.should.run=false"
# A custom folder where we will deploy .jar
set :jar_deploy_folder, "#{ release_path }/local-release"
# The kune-data/ folder
set :data_folder, "#{ jar_deploy_folder }/kune-data"
# A custom folder to place the static web resources
set :webapp_deploy_folder, "#{ jar_deploy_folder }/webapp"
# A custom folder to place config files
set :config_folder, "#{ jar_deploy_folder }/config"
# Deploy binary .jar file
run "cp #{ release_path }/target/kune-*-complete.jar #{ jar_deploy_folder }"
# Deploy Webapp files
%w{ css object-embed-devel.html others static tutorials wse-dev.html wse.html ws.html }.each do |file|
run "cp -r #{ release_path }/src/main/webapp/#{ file } #{ webapp_deploy_folder }"
end
%w{ web.xml localhost.cer localhost.key }.each do |file|
run "cp -r #{ release_path }/src/main/webapp/WEB-INF/#{ file } #{ webapp_deploy_folder }/WEB-INF"
end
# Deploy GWT files
%w{ ws wse }.each do |file|
run "cp -r #{ release_path }/target/kune-*/#{ file } #{ webapp_deploy_folder }"
end
# Configuration
run "ln -s /etc/kune #{ jar_deploy_folder }/config"
# Data
run "ln -s #{ shared_path}/kune-data #{ data_folder }"
# Backup database
run "mkdir -p #{ current_path }/bck"
run "mysqldump -u kune -p#{ db_pwd } kune_prod > #{ current_path }/bck/mysql.dump"
end
task :restart, roles: :app, except: { no_release: true } do
run "cd #{ release_path }/local-release && ./restart.sh"
end
end