github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

andynu / capistrano-recipes

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 5
    • 4
  • Source
  • Commits
  • Network (4)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

a series of capistrano deployment and administration recipes. — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

add force flag to war symlink 
andynu (author)
Sun Dec 06 16:28:02 -0800 2009
commit  5daceb22e44b0c3567b033db75ffd1533be94332
tree    2b0918607f0dea3861f8bf0bc627b431fe8d6447
parent  e82f367ad07afa6cf0d9864fbfbd6f494269ad0b
capistrano-recipes / capfile_tomcat capfile_tomcat
100644 130 lines (108 sloc) 2.662 kb
edit raw blame history
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/ruby
 
load 'deploy'
 
set :application, "my-webapp"
 
default_run_options[:pty] = true
 
# DEPLOYMENT SCHEME
set :scm, :none
set :deploy_via, :copy
set :repository do
  fetch(:deploy_from)
end
 
# LOCAL
set :war, "/home/andy/webapps/my-webapp/target/my-webapp.war"
 
# TOMCAT SERVERS
role :webserver, "testserver"
set :tomcat_home, "/usr/share/tomcat55/"
set :tomcat_ctrl, "/etc/init.d/tomcat55"
 
# USER / SHELL
set :user, "testuser" # the user to run remote commands as
set :use_sudo, false
 
set :deploy_from do
  dir = "/tmp/prep_#{release_name}"
  system("mkdir -p #{dir}")
  dir
end
 
# this is capistrano's default location.
# depending on the permissions of the server
# you may need to create it and chown it over
# to :user (e.g. chown -R robotuser:robotuser /u)
set :deploy_to do
  "/u/apps/#{application}"
end
 
#
# simple interactions with the tomcat server
#
namespace :tomcat do
 
  desc "start tomcat"
  task :start do
    sudo "#{tomcat_ctrl} start"
  end
 
  desc "stop tomcat"
  task :stop do
    sudo "#{tomcat_ctrl} stop"
  end
 
  desc "stop and start tomcat"
  task :restart do
    tomcat.stop
    tomcat.start
  end
 
  desc "tail :tomcat_home/logs/*.log and logs/catalina.out"
  task :tail do
    stream "tail -f #{tomcat_home}/logs/*.log #{tomcat_home}/logs/catalina.out"
  end
 
end
 
#
# link the current/whatever.war into our webapps/whatever.war
#
after 'deploy:setup' do
  cmd = "ln -sf #{deploy_to}/current/`basename #{war}` #{tomcat_home}/webapps/`basename #{war}`"
  puts cmd
  sudo cmd
end
 
# collect up our war into the deploy_from folder
# notice that all we're doing is a copy here,
# so it is pretty easy to swap this out for
# a wget command, which makes sense if you're
# using a continuous integration server like
# bamboo. (more on this later).
before 'deploy:update_code' do
  unless(war.nil?)
    puts "get war"
    system("cp #{war} #{deploy_from}")
    puts system("ls -l #{deploy_from}")
  end
end
 
# restart tomcat
namespace :deploy do
  task :restart do
    tomcat.restart
  end
end
 
#
# Disable all the default tasks that
# either don't apply, or I haven't made work.
#
namespace :deploy do
  [ :upload, :cold, :start, :stop, :migrate, :migrations ].each do |default_task|
    desc "[internal] disabled"
    task default_task do
      # disabled
    end
  end
 
  namespace :web do
    [ :disable, :enable ].each do |default_task|
      desc "[internal] disabled"
      task default_task do
        # disabled
      end
    end
  end
 
  namespace :pending do
    [ :default, :diff ].each do |default_task|
      desc "[internal] disabled"
      task default_task do
        # disabled
      end
    end
  end
end
 
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server