crazycode-cap-recipes 0.3.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +20 -0
- data/README.textile +586 -0
- data/Rakefile +57 -0
- data/VERSION.yml +5 -0
- data/bin/cap-recipes +4 -0
- data/cap-recipes.gemspec +128 -0
- data/examples/advanced/deploy.rb +39 -0
- data/examples/advanced/deploy/experimental.rb +14 -0
- data/examples/advanced/deploy/production.rb +20 -0
- data/examples/simple/deploy.rb +36 -0
- data/lib/cap_recipes.rb +1 -0
- data/lib/cap_recipes/tasks/apache.rb +1 -0
- data/lib/cap_recipes/tasks/apache/install.rb +16 -0
- data/lib/cap_recipes/tasks/apache/manage.rb +26 -0
- data/lib/cap_recipes/tasks/aptitude.rb +1 -0
- data/lib/cap_recipes/tasks/aptitude/manage.rb +32 -0
- data/lib/cap_recipes/tasks/backgroundrb.rb +1 -0
- data/lib/cap_recipes/tasks/backgroundrb/hooks.rb +5 -0
- data/lib/cap_recipes/tasks/backgroundrb/manage.rb +64 -0
- data/lib/cap_recipes/tasks/bundler.rb +1 -0
- data/lib/cap_recipes/tasks/bundler/manage.rb +31 -0
- data/lib/cap_recipes/tasks/delayed_job.rb +1 -0
- data/lib/cap_recipes/tasks/delayed_job/hooks.rb +5 -0
- data/lib/cap_recipes/tasks/delayed_job/manage.rb +34 -0
- data/lib/cap_recipes/tasks/ec2/install.rb +32 -0
- data/lib/cap_recipes/tasks/ec2/manage.rb +32 -0
- data/lib/cap_recipes/tasks/gitosis.rb +1 -0
- data/lib/cap_recipes/tasks/gitosis/install.rb +58 -0
- data/lib/cap_recipes/tasks/gitosis/manage.rb +3 -0
- data/lib/cap_recipes/tasks/hudson.rb +1 -0
- data/lib/cap_recipes/tasks/hudson/manage.rb +33 -0
- data/lib/cap_recipes/tasks/jetty.rb +1 -0
- data/lib/cap_recipes/tasks/jetty/install.rb +33 -0
- data/lib/cap_recipes/tasks/jetty/manage.rb +34 -0
- data/lib/cap_recipes/tasks/jetty/web.rb +98 -0
- data/lib/cap_recipes/tasks/juggernaut.rb +3 -0
- data/lib/cap_recipes/tasks/juggernaut/hooks.rb +4 -0
- data/lib/cap_recipes/tasks/juggernaut/manage.rb +56 -0
- data/lib/cap_recipes/tasks/maven.rb +85 -0
- data/lib/cap_recipes/tasks/memcache.rb +3 -0
- data/lib/cap_recipes/tasks/memcache/hooks.rb +5 -0
- data/lib/cap_recipes/tasks/memcache/install.rb +15 -0
- data/lib/cap_recipes/tasks/memcache/manage.rb +37 -0
- data/lib/cap_recipes/tasks/mongodb.rb +1 -0
- data/lib/cap_recipes/tasks/mongodb/install.rb +137 -0
- data/lib/cap_recipes/tasks/mongodb/manage.rb +27 -0
- data/lib/cap_recipes/tasks/passenger.rb +1 -0
- data/lib/cap_recipes/tasks/passenger/install.rb +72 -0
- data/lib/cap_recipes/tasks/passenger/manage.rb +23 -0
- data/lib/cap_recipes/tasks/rails.rb +1 -0
- data/lib/cap_recipes/tasks/rails/hooks.rb +6 -0
- data/lib/cap_recipes/tasks/rails/manage.rb +51 -0
- data/lib/cap_recipes/tasks/ruby.rb +1 -0
- data/lib/cap_recipes/tasks/ruby/install.rb +16 -0
- data/lib/cap_recipes/tasks/rubygems.rb +1 -0
- data/lib/cap_recipes/tasks/rubygems/install.rb +22 -0
- data/lib/cap_recipes/tasks/rubygems/manage.rb +43 -0
- data/lib/cap_recipes/tasks/templates/hudson.erb +85 -0
- data/lib/cap_recipes/tasks/templates/mongod.conf.erb +89 -0
- data/lib/cap_recipes/tasks/templates/mongodb.init.erb +73 -0
- data/lib/cap_recipes/tasks/templates/mongodb.repo.erb +4 -0
- data/lib/cap_recipes/tasks/templates/mongos.init.erb +69 -0
- data/lib/cap_recipes/tasks/templates/tomcat.erb +95 -0
- data/lib/cap_recipes/tasks/thinking_sphinx.rb +1 -0
- data/lib/cap_recipes/tasks/thinking_sphinx/hooks.rb +4 -0
- data/lib/cap_recipes/tasks/thinking_sphinx/install.rb +17 -0
- data/lib/cap_recipes/tasks/thinking_sphinx/manage.rb +65 -0
- data/lib/cap_recipes/tasks/tomcat.rb +1 -0
- data/lib/cap_recipes/tasks/tomcat/install.rb +43 -0
- data/lib/cap_recipes/tasks/tomcat/manage.rb +34 -0
- data/lib/cap_recipes/tasks/tomcat/war.rb +98 -0
- data/lib/cap_recipes/tasks/utilities.rb +172 -0
- data/lib/cap_recipes/tasks/whenever.rb +1 -0
- data/lib/cap_recipes/tasks/whenever/hooks.rb +5 -0
- data/lib/cap_recipes/tasks/whenever/manage.rb +8 -0
- data/lib/cap_recipes/tasks/yum.rb +1 -0
- data/lib/cap_recipes/tasks/yum/manage.rb +30 -0
- data/lib/capify.rb +35 -0
- data/lib/templates/Capfile.tt +4 -0
- data/lib/templates/deploy.rb.tt +30 -0
- data/spec/cap/all/Capfile +2 -0
- data/spec/cap/helper.rb +3 -0
- data/spec/cap_recipes_spec.rb +56 -0
- data/spec/spec_helper.rb +37 -0
- data/specs.watchr +35 -0
- metadata +155 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Dir[File.join(File.dirname(__FILE__), 'bundler/*.rb')].sort.each { |lib| require lib }
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Capistrano::Configuration.instance(true).load do
|
|
2
|
+
|
|
3
|
+
namespace :bundle do
|
|
4
|
+
desc "Runs Gem Bundle after deployment"
|
|
5
|
+
task :install do
|
|
6
|
+
run "cd #{deploy_to}/current; bundle install"
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
desc "lock bundle"
|
|
10
|
+
task :lock do
|
|
11
|
+
run "cd #{deploy_to}/current; bundle lock"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
desc "unlock bundle"
|
|
15
|
+
task :unlock do
|
|
16
|
+
run "cd #{deploy_to}/current; bundle unlock"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
desc "show bundle"
|
|
20
|
+
task :show do
|
|
21
|
+
run "cd #{deploy_to}/current; bundle show"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
desc "bundle check"
|
|
25
|
+
task :check do
|
|
26
|
+
run "cd #{deploy_to}/current; bundle check"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Dir[File.join(File.dirname(__FILE__), 'delayed_job/*.rb')].sort.each { |lib| require lib }
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../utilities')
|
|
2
|
+
|
|
3
|
+
Capistrano::Configuration.instance(true).load do
|
|
4
|
+
set :delayed_script_path, "#{current_path}/script/delayed_job"
|
|
5
|
+
set :delayed_job_env, 'production'
|
|
6
|
+
set :delayed_job_role, :app
|
|
7
|
+
set :base_ruby_path, '/usr'
|
|
8
|
+
|
|
9
|
+
namespace :delayed_job do
|
|
10
|
+
desc "Start delayed_job process"
|
|
11
|
+
task :start, :roles => delayed_job_role do
|
|
12
|
+
utilities.with_role(delayed_job_role) do
|
|
13
|
+
try_sudo "RAILS_ENV=#{delayed_job_env} #{base_ruby_path}/bin/ruby #{delayed_script_path} start"
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
desc "Stop delayed_job process"
|
|
18
|
+
task :stop, :roles => delayed_job_role do
|
|
19
|
+
utilities.with_role(delayed_job_role) do
|
|
20
|
+
try_sudo "RAILS_ENV=#{delayed_job_env} #{base_ruby_path}/bin/ruby #{delayed_script_path} stop"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
desc "Restart delayed_job process"
|
|
25
|
+
task :restart, :roles => delayed_job_role do
|
|
26
|
+
utilities.with_role(delayed_job_role) do
|
|
27
|
+
delayed_job.stop
|
|
28
|
+
sleep(4)
|
|
29
|
+
try_sudo "killall -s TERM delayed_job; true"
|
|
30
|
+
delayed_job.start
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'cap_recipes/tasks/utilities.rb'
|
|
2
|
+
|
|
3
|
+
Capistrano::Configuration.instance(true).load do
|
|
4
|
+
|
|
5
|
+
set :install_path, "/usr/local/"
|
|
6
|
+
|
|
7
|
+
namespace :ec2 do
|
|
8
|
+
desc "install the ec2-amitools"
|
|
9
|
+
task :install do
|
|
10
|
+
run "unzip ec2-ami-tools.zip -d #{install_path}"
|
|
11
|
+
end
|
|
12
|
+
before "ec2:install", "ec2:install_dependencies"
|
|
13
|
+
before "ec2:install", "ec2:download"
|
|
14
|
+
|
|
15
|
+
desc "download the ec2-amitools"
|
|
16
|
+
task :download do
|
|
17
|
+
run "wget http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.zip" unless File.exists? "ec2-ami-tools.zip"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
desc "install the ec2 dependencies"
|
|
21
|
+
task :install_dependencies do
|
|
22
|
+
utilities.apt_install %w[curl gzip openssl rsync]
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
desc "export ec2-ami-tools to EC2_AMITOOL_HOME and PATH"
|
|
26
|
+
task :export do
|
|
27
|
+
run "export EC2_AMITOOL_HOME=#{install_path}/ec2-ami-tools"
|
|
28
|
+
run "export PATH=$PATH:${EC2_AMITOOL_HOME}/bin"
|
|
29
|
+
end
|
|
30
|
+
after "ec2:install", "ec2:export"
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'cap_recipes/tasks/utilities.rb'
|
|
2
|
+
|
|
3
|
+
Capistrano::Configuration.instance(true).load do
|
|
4
|
+
|
|
5
|
+
=begin # Set these vars.
|
|
6
|
+
ssh_options[:keys] = [File.join(ENV["HOME"], ".ssh", "id_rsa.pub")]
|
|
7
|
+
|
|
8
|
+
set :public_key, "id-KEYNAME" # the keypair to use for the instance
|
|
9
|
+
set :cert_code, "CERT_CODE" # the code for the private key and for the certificate
|
|
10
|
+
set :bundle_host, "DOMAIN.com" # the domain for the site
|
|
11
|
+
set :account_id, "ACCOUNTID" # your account_id without dashes
|
|
12
|
+
set :bundle_name, "BUNDLE" # the name of the bundle
|
|
13
|
+
set :store_bucket, "BUCKET" # the name of the bucket
|
|
14
|
+
set :access_key_id, "ACCESS KEY"
|
|
15
|
+
set :access_secret_key, "SECRET KEY"
|
|
16
|
+
=end
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
namespace :ec2 do
|
|
20
|
+
desc "bundles up our innercalm image"
|
|
21
|
+
task :bundle do
|
|
22
|
+
utilities.with_credentials :user => 'root' do
|
|
23
|
+
system("scp -i ~/.ec2/#{public_key} ~/.ec2/pk-#{cert_code}.pem ~/.ec2/cert-#{cert_code}.pem root@#{bundle_host}:/mnt")
|
|
24
|
+
run "rm -f /mnt/#{bundle_name}"
|
|
25
|
+
run "export PATH=/usr/bin:$PATH; ec2-bundle-vol -d /mnt -k /mnt/pk-#{cert_code}.pem -c /mnt/cert-#{cert_code}.pem -u #{account_id} -r i386 -p #{bundle_name}"
|
|
26
|
+
run "ls -l /mnt/#{bundle_name}.*"
|
|
27
|
+
run "export PATH=/usr/bin:$PATH; ec2-upload-bundle -b #{store_bucket} -m /mnt/#{bundle_name}.manifest.xml -a #{access_key_id} -s #{access_secret_key}"
|
|
28
|
+
system("ec2-register #{store_bucket}/#{bundle_name}.manifest.xml")
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Dir[File.join(File.dirname(__FILE__), 'gitosis/*.rb')].sort.each { |lib| require lib }
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../utilities')
|
|
2
|
+
|
|
3
|
+
Capistrano::Configuration.instance(true).load do
|
|
4
|
+
|
|
5
|
+
namespace :gitosis do
|
|
6
|
+
desc "install Gitosis"
|
|
7
|
+
task :install do
|
|
8
|
+
gitosis.install_packages
|
|
9
|
+
gitosis.setup_packages
|
|
10
|
+
gitosis.setup_git_user
|
|
11
|
+
gitosis.copy_ssh
|
|
12
|
+
gitosis.set_permissions
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
desc "install all necessary packages"
|
|
16
|
+
task :install_packages do
|
|
17
|
+
utilities.apt_install %[git-core python-setuptools]
|
|
18
|
+
end
|
|
19
|
+
before "gitosis:install_packages", "aptitude:updates"
|
|
20
|
+
|
|
21
|
+
desc "setup packages"
|
|
22
|
+
task :setup_packages do
|
|
23
|
+
run "mkdir -p ~/src"
|
|
24
|
+
run "cd ~/src; git clone git://eagain.net/gitosis.git"
|
|
25
|
+
run "cd ~/src/gitosis; #{sudo} python setup.py install"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
desc "setup git user"
|
|
29
|
+
task :setup_git_user do
|
|
30
|
+
sudo "adduser --system --shell /bin/sh --gecos \'git version control\' --group --disabled-password --home /home/git git"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
desc "generate ssh key"
|
|
34
|
+
task :generate_ssh do
|
|
35
|
+
run "rm -f /home/#{user}/.ssh/id_rsa; rm -f /home/#{user}/.ssh/id_rsa.pub"
|
|
36
|
+
run "ssh-keygen -q -f /home/#{user}/.ssh/id_rsa -N \"\""
|
|
37
|
+
end
|
|
38
|
+
before "gitosis:copy_ssh", "gitosis:generate_ssh"
|
|
39
|
+
|
|
40
|
+
desc "copy over servers own ssh, important for self pull"
|
|
41
|
+
task :copy_ssh do
|
|
42
|
+
run "sudo -H -u git gitosis-init < /home/#{user}/.ssh/id_rsa.pub"
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
desc "set permissions"
|
|
46
|
+
task :set_permissions do
|
|
47
|
+
sudo "chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
desc "cleanup the files"
|
|
51
|
+
task :cleanup do
|
|
52
|
+
sudo "rm -rf src"
|
|
53
|
+
end
|
|
54
|
+
before "gitosis:setup_packages", "gitosis:cleanup"
|
|
55
|
+
after "gitosis:setup_packages", "gitosis:cleanup"
|
|
56
|
+
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Dir[File.join(File.dirname(__FILE__), 'hudson/*.rb')].sort.each { |lib| require lib }
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../utilities')
|
|
3
|
+
|
|
4
|
+
Capistrano::Configuration.instance(true).load do
|
|
5
|
+
# HUDSON SERVERS
|
|
6
|
+
_cset :hudson_home, "/opt/hudson"
|
|
7
|
+
_cset :hudson_ctrl, "/etc/init.d/hudson"
|
|
8
|
+
|
|
9
|
+
#
|
|
10
|
+
# simple interactions with the hudson server
|
|
11
|
+
#
|
|
12
|
+
namespace :hudson do
|
|
13
|
+
|
|
14
|
+
desc "install hudson"
|
|
15
|
+
task :install do
|
|
16
|
+
dir = File.dirname(hudson_home)
|
|
17
|
+
basename = File.basename(hudson_file)
|
|
18
|
+
basectl = File.basename(hudson_ctrl)
|
|
19
|
+
puts "#{hudson_file} ,,,, #{dir} /#{basename}"
|
|
20
|
+
utilities.sudo_upload "#{hudson_file}", "#{dir}/#{basename}"
|
|
21
|
+
sudo "tar -zvxf #{dir}/#{basename} -C #{dir}"
|
|
22
|
+
sudo "chown #{user}:root #{hudson_home} -R"
|
|
23
|
+
|
|
24
|
+
put utilities.render("hudson", binding), "hudson.tmp"
|
|
25
|
+
sudo "cp hudson.tmp #{hudson_ctrl}"
|
|
26
|
+
sudo "chmod a+x #{hudson_ctrl}"
|
|
27
|
+
sudo "/sbin/chkconfig --add #{basectl}"
|
|
28
|
+
run "rm hudson.tmp"
|
|
29
|
+
sudo "rm #{dir}/#{basename}"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Dir[File.join(File.dirname(__FILE__), 'jetty/*.rb')].sort.each { |lib| require lib }
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../utilities')
|
|
3
|
+
|
|
4
|
+
Capistrano::Configuration.instance(true).load do
|
|
5
|
+
# JETTY SERVERS
|
|
6
|
+
_cset :jetty_home, "/usr/local/jetty-7.1.6"
|
|
7
|
+
_cset :jetty_ctrl, "/etc/init.d/jetty"
|
|
8
|
+
|
|
9
|
+
#
|
|
10
|
+
# simple interactions with the jetty server
|
|
11
|
+
#
|
|
12
|
+
namespace :jetty do
|
|
13
|
+
|
|
14
|
+
desc "install jetty"
|
|
15
|
+
task :install do
|
|
16
|
+
dir = File.dirname(jetty_home)
|
|
17
|
+
basename = File.basename(jetty_file)
|
|
18
|
+
basectl = File.basename(jetty_ctrl)
|
|
19
|
+
puts "#{jetty_file} ,,,, #{dir} /#{basename}"
|
|
20
|
+
utilities.sudo_upload "#{jetty_file}", "#{dir}/#{basename}"
|
|
21
|
+
sudo "tar -zvxf #{dir}/#{basename} -C #{dir}"
|
|
22
|
+
sudo "chown #{user}:root #{jetty_home} -R"
|
|
23
|
+
|
|
24
|
+
put utilities.render("jetty", binding), "jetty.tmp"
|
|
25
|
+
sudo "cp jetty.tmp #{jetty_ctrl}"
|
|
26
|
+
sudo "chmod a+x #{jetty_ctrl}"
|
|
27
|
+
sudo "/sbin/chkconfig --add #{basectl}"
|
|
28
|
+
run "rm jetty.tmp"
|
|
29
|
+
sudo "rm #{dir}/#{basename}"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Capistrano::Configuration.instance(true).load do
|
|
2
|
+
#
|
|
3
|
+
# simple interactions with the jetty server
|
|
4
|
+
#
|
|
5
|
+
namespace :jetty do
|
|
6
|
+
|
|
7
|
+
desc "start jetty"
|
|
8
|
+
task :start do
|
|
9
|
+
sudo "#{jetty_ctrl} start"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
desc "stop jetty"
|
|
13
|
+
task :stop do
|
|
14
|
+
sudo "#{jetty_ctrl} stop"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
desc "stop and start jetty"
|
|
18
|
+
task :restart do
|
|
19
|
+
jetty.stop
|
|
20
|
+
jetty.start
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
desc "list jetty process"
|
|
24
|
+
task :ps do
|
|
25
|
+
run "ps aux | grep jetty | grep -v grep"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
desc "tail :jetty_home/logs/*.log and logs/catalina.out"
|
|
29
|
+
task :tail do
|
|
30
|
+
stream "tail -f #{jetty_home}/logs/*.log"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../utilities')
|
|
2
|
+
|
|
3
|
+
Capistrano::Configuration.instance(true).load do
|
|
4
|
+
# DEPLOYMENT SCHEME
|
|
5
|
+
set :scm, :none
|
|
6
|
+
set :deploy_via, :copy
|
|
7
|
+
set :use_sudo, true
|
|
8
|
+
|
|
9
|
+
_cset :deploy_to_parent, "/srv/applications"
|
|
10
|
+
|
|
11
|
+
default_run_options[:pty] = true
|
|
12
|
+
|
|
13
|
+
set :keep_releases, 5
|
|
14
|
+
|
|
15
|
+
set :repository do
|
|
16
|
+
fetch(:deploy_from)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
set :deploy_from do
|
|
20
|
+
dir = "/tmp/prep_#{release_name}"
|
|
21
|
+
system("mkdir -p #{dir}")
|
|
22
|
+
dir
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# this is capistrano's default location.
|
|
26
|
+
# depending on the permissions of the server
|
|
27
|
+
# you may need to create it and chown it over
|
|
28
|
+
# to :user (e.g. chown -R robotuser:robotuser /u)
|
|
29
|
+
set :deploy_to do
|
|
30
|
+
dir = "#{deploy_to_parent}/#{application}"
|
|
31
|
+
sudo "mkdir -p #{dir}"
|
|
32
|
+
sudo "chown #{user} #{dir}"
|
|
33
|
+
dir
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
#
|
|
37
|
+
# link the current/whatever.war into our webapps/whatever.war
|
|
38
|
+
#
|
|
39
|
+
#after 'deploy:setup' do
|
|
40
|
+
# cmd = "ln -s #{deploy_to}/current/`basename #{war}` #{jetty_home}/webapps/`basename #{war}`"
|
|
41
|
+
# puts cmd
|
|
42
|
+
# sudo cmd
|
|
43
|
+
#end
|
|
44
|
+
|
|
45
|
+
# collect up our war into the deploy_from folder
|
|
46
|
+
# notice that all we're doing is a copy here,
|
|
47
|
+
# so it is pretty easy to swap this out for
|
|
48
|
+
# a wget command, which makes sense if you're
|
|
49
|
+
# using a continuous integration server like
|
|
50
|
+
# bamboo. (more on this later).
|
|
51
|
+
before 'deploy:update_code' do
|
|
52
|
+
unless(war.nil?)
|
|
53
|
+
puts "get war"
|
|
54
|
+
system("mkdir #{deploy_from}/webapp")
|
|
55
|
+
system("cp #{war} #{deploy_from}/webapp")
|
|
56
|
+
system("cd #{deploy_from}/webapp && jar xf `basename #{war}`")
|
|
57
|
+
system("rm -Rf #{deploy_from}/webapp/META-INF")
|
|
58
|
+
system("rm #{deploy_from}/webapp/`basename #{war}`")
|
|
59
|
+
puts system("ls -l #{deploy_from}")
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
#
|
|
64
|
+
# Disable all the default tasks that
|
|
65
|
+
# either don't apply, or I haven't made work.
|
|
66
|
+
#
|
|
67
|
+
namespace :deploy do
|
|
68
|
+
# restart jetty
|
|
69
|
+
task :restart do
|
|
70
|
+
jetty.restart
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
[ :upload, :cold, :start, :stop, :migrate, :migrations, :finalize_update ].each do |default_task|
|
|
74
|
+
desc "[internal] disabled"
|
|
75
|
+
task default_task do
|
|
76
|
+
# disabled
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
namespace :web do
|
|
81
|
+
[ :disable, :enable ].each do |default_task|
|
|
82
|
+
desc "[internal] disabled"
|
|
83
|
+
task default_task do
|
|
84
|
+
# disabled
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
namespace :pending do
|
|
90
|
+
[ :default, :diff ].each do |default_task|
|
|
91
|
+
desc "[internal] disabled"
|
|
92
|
+
task default_task do
|
|
93
|
+
# disabled
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../utilities')
|
|
2
|
+
|
|
3
|
+
Capistrano::Configuration.instance(true).load do
|
|
4
|
+
set :juggernaut_config, "#{current_path}/config/juggernaut.yml"
|
|
5
|
+
set :juggernaut_pid, "#{current_path}/tmp/pids/juggernaut.pid"
|
|
6
|
+
set :juggernaut_log, "#{current_path}/log/juggernaut.log"
|
|
7
|
+
set :juggernaut_role, :app
|
|
8
|
+
set :base_ruby_path, '/usr'
|
|
9
|
+
|
|
10
|
+
namespace :juggernaut do
|
|
11
|
+
|
|
12
|
+
# ===============================================================
|
|
13
|
+
# PROCESS MANAGEMENT
|
|
14
|
+
# ===============================================================
|
|
15
|
+
|
|
16
|
+
desc "Starts the juggernaut push server"
|
|
17
|
+
task :start, :roles => juggernaut_role do
|
|
18
|
+
utilities.with_role(juggernaut_role) do
|
|
19
|
+
puts "Starting juggernaut push server"
|
|
20
|
+
try_sudo "#{base_ruby_path}/bin/juggernaut -c #{juggernaut_config} -d --pid #{juggernaut_pid} --log #{juggernaut_log}"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
desc "Stops the juggernaut push server"
|
|
25
|
+
task :stop, :roles => juggernaut_role do
|
|
26
|
+
utilities.with_role(juggernaut_role) do
|
|
27
|
+
puts "Stopping juggernaut push server"
|
|
28
|
+
try_sudo "#{base_ruby_path}/bin/juggernaut -c #{juggernaut_config} -k * --pid #{juggernaut_pid} --log #{juggernaut_log}"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
desc "Restarts the juggernaut push server"
|
|
33
|
+
task :restart, :roles => juggernaut_role do
|
|
34
|
+
utilities.with_role(juggernaut_role) do
|
|
35
|
+
juggernaut.stop
|
|
36
|
+
juggernaut.start
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# ===============================================================
|
|
41
|
+
# FILE MANAGEMENT
|
|
42
|
+
# ===============================================================
|
|
43
|
+
|
|
44
|
+
desc "Symlinks the shared/config/juggernaut yaml to release/config/"
|
|
45
|
+
task :symlink_config, :roles => :app do
|
|
46
|
+
try_sudo "ln -s #{shared_path}/config/juggernaut.yml #{release_path}/config/juggernaut.yml"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
desc "Displays the juggernaut log from the server"
|
|
50
|
+
task :tail, :roles => :app do
|
|
51
|
+
stream "tail -f #{shared_path}/log/juggernaut.log"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|