railslove_deploy 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@ namespace :backup do
2
2
 
3
3
  desc "Create a new backup using the astrails-safe config script from config/server/backup.rb"
4
4
  task :run do
5
- sudo "cd #{current_path}; /usr/local/ruby-enterprise/bin/astrails-safe -v #{current_path}/config/server/backup.rb"
5
+ sudo "cd #{current_path}; /usr/local/ruby-enterprise/bin/astrails-safe -v #{current_path}/config/server/#{fetch(:backup_script, "backup.rb")}"
6
6
  end
7
7
 
8
8
  end
@@ -10,21 +10,23 @@ namespace :hooks do
10
10
  url = URI.parse("http://twitter.com/statuses/update.json")
11
11
 
12
12
  status = Capistrano::CLI.ui.ask("Update Twitter status to: (leave blank to skip)")
13
+ user = fetch(:twitter_user, nil).nil? ? Capistrano::CLI.ui.ask("Twitter username: ") : fetch(:twitter_user, nil)
14
+ passwd = fetch(:twitter_password, nil).nil? ? Capistrano::CLI.password_prompt("Twitter password for @#{user}: ") : fetch(:twitter_password, nil)
13
15
  unless status.empty?
14
16
 
15
17
  http = Net::HTTP.new(url.host, 80)
16
18
  http.open_timeout = 20
17
19
 
18
- headers = {'Authorization' => 'Basic ' + ["#{twitter_user}:#{twitter_password}"].pack('m').delete("\r\n")}
20
+ headers = {'Authorization' => 'Basic ' + ["#{user}:#{passwd}"].pack('m').delete("\r\n")}
19
21
 
20
22
  body = "status=#{CGI.escape(status)}"
21
23
  begin
22
24
  http.send(:post, url.path, body, headers)
25
+ puts "Status updated..."
23
26
  rescue Timeout::Error => e
24
27
  puts "Timeout after 20s: Seems like Twitter is down."
25
- puts "Use \"cap twitter:update\" to update Twitter status later w/o deploying"
28
+ puts "Use \"cap hooks:twitter:update\" to update Twitter status later w/o deploying"
26
29
  end
27
- # if an exception is thrown, let them see it, they're a developer (most likely)
28
30
  end
29
31
  end
30
32
  end
@@ -0,0 +1,10 @@
1
+ namespace :munin_node do
2
+
3
+ desc "Upload the munin node configuration"
4
+ task :configure do
5
+ put render("config/server/munin-node.conf.erb", binding), "/tmp/munin_node"
6
+ sudo "mv /tmp/munin_node /etc/munin/munin-node.conf"
7
+ sudo "chown -R root:root /etc/munin/munin-node.conf"
8
+ end
9
+
10
+ end
@@ -1,15 +1,19 @@
1
1
  namespace :shared do
2
+
3
+ # source is the file/folder within the release
4
+ # target is the file/folder in the shared folder
5
+
2
6
  task :setup do
3
7
  fetch(:shared_files,{}).each do |source,target|
4
- path = File.directory?(source) ? File.dirname(target) : target
8
+ path = File.directory?(source) ? target : File.dirname(target)
5
9
  run "mkdir -p #{shared_path}/#{path}"
6
10
  end
7
11
  end
8
12
 
9
13
  task :symlink do
10
14
  fetch(:shared_files,{}).each do |source,target|
11
- run "rm -rf #{source}"
12
- run "ln -s #{shared_path}/#{target} #{release_path}/#{source}"
15
+ run "rm -rf #{release_path}/#{source}"
16
+ run "ln -nfs #{shared_path}/#{target} #{release_path}/#{source}"
13
17
  end
14
18
  end
15
19
 
@@ -9,9 +9,9 @@ package :monit, :provides => :monitoring do
9
9
 
10
10
  requires :essentials, :monit_dependencies
11
11
 
12
- #verify do
13
- # has_executable "monit"
14
- #end
12
+ verify do
13
+ has_executable "monit"
14
+ end
15
15
  end
16
16
 
17
17
  package :monit_init_d do
@@ -22,9 +22,9 @@ package :monit_init_d do
22
22
  post :install, "chmod +x /etc/init.d/monit"
23
23
  end
24
24
 
25
- #verify do
26
- # has_file "/etc/init.d/monit"
27
- #end
25
+ verify do
26
+ has_file "/etc/init.d/monit"
27
+ end
28
28
 
29
29
  end
30
30
 
@@ -0,0 +1,31 @@
1
+ package :munin_node do
2
+ description 'munin-node - daemon to gather system ressouce information in cooperation with the main Munin program'
3
+ requires :essentials
4
+ # the apache stats for munin need libwww-perl
5
+ apt 'munin-node libwww-perl'
6
+
7
+ verify do
8
+ has_executable "munin-node"
9
+ end
10
+ end
11
+
12
+ package :munin_apache_status do
13
+ description "Configure the Munin node for extended apache process, access and volumne information"
14
+ requires :munin_node
15
+
16
+ noop do
17
+ post :install, "ln -s /usr/share/munin/plugins/apache_accesses /etc/munin/plugins/"
18
+ post :install, "ln -s /usr/share/munin/plugins/apache_processes /etc/munin/plugins/"
19
+ post :install, "ln -s /usr/share/munin/plugins/apache_volume /etc/munin/plugins/"
20
+ post :install, 'sed -e "s/<\/IfModule>/ExtendedStatus On \n<\/IfModule>/g" /etc/apache2/mods-available/status.conf > /etc/apache2/mods-available/status.conf'
21
+ end
22
+ end
23
+
24
+ package :munin do
25
+ description "Munin is a networked resource monitoring tool that can help analyze resource trends"
26
+ apt 'munin'
27
+
28
+ verify do
29
+ has_executable "munin"
30
+ end
31
+ end
@@ -1,6 +1,6 @@
1
1
  package :passenger_gem do
2
2
  description 'Phusion Passenger (aka mod_rails)'
3
- version '2.2.8'
3
+ version '2.2.9'
4
4
  gem 'passenger'
5
5
  requires :ruby_enterprise
6
6
 
@@ -14,7 +14,7 @@ package :passenger_apache, :provides => :appserver do
14
14
  # require the apache passenger module load/conf files before installation because of a sprinkle limitation.
15
15
  requires :apache, :passenger_gem, :passenger_module_load, :passenger_module_conf
16
16
 
17
- passenger_version = '2.2.8'
17
+ passenger_version = '2.2.9'
18
18
 
19
19
  noop do
20
20
  pre :install, 'passenger-install-apache2-module --auto'
@@ -25,7 +25,7 @@ package :passenger_apache, :provides => :appserver do
25
25
  end
26
26
 
27
27
  verify do
28
- has_file '/usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.8/ext/apache2/mod_passenger.so'
28
+ has_file '/usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.9/ext/apache2/mod_passenger.so'
29
29
  end
30
30
  end
31
31
 
@@ -35,7 +35,7 @@ package :passenger_module_load do
35
35
  requires :apache, :passenger_gem
36
36
 
37
37
  #TODO: :render => true seems not to work? hello sprinkle?!
38
- passenger_version = '2.2.8'
38
+ passenger_version = '2.2.9'
39
39
  transfer "#{File.dirname(__FILE__)}/../templates/passenger.load", "/etc/apache2/mods-available/passenger.load", :render => true
40
40
 
41
41
  verify do
@@ -49,7 +49,7 @@ package :passenger_module_conf do
49
49
  requires :apache, :passenger_gem
50
50
 
51
51
  #TODO: :render => true seems not to work? hello sprinkle?!
52
- passenger_version = '2.2.8'
52
+ passenger_version = '2.2.9'
53
53
  transfer "#{File.dirname(__FILE__)}/../templates/passenger.conf", "/etc/apache2/mods-available/passenger.conf", :render => true
54
54
 
55
55
  verify do
@@ -77,8 +77,11 @@ set :use_sudo, false
77
77
 
78
78
  # the files and directories that you want to share between the releases of your application
79
79
  # for example:
80
- # set :shared_files, {:files => "files"}
81
- # symlinks <release>/files to <shared>/files and
80
+ # set :shared_files, {"public/files" => "files"}
81
+ # symlinks <release>/public/files to <shared>/files and
82
+ # set :shared_files, {"config/myconf.rb" => "config/myconfig.rb"}
83
+ # symlinks <release>/config/myconfig.rb to <shared>/config/myconfig.rb and
84
+
82
85
 
83
86
  set :shared_files, {}
84
87
 
@@ -137,6 +140,19 @@ after "deploy:setup",
137
140
  "ferm:configure"
138
141
 
139
142
 
143
+ #############################################################################
144
+ # Munin configuration
145
+ #############################################################################
146
+
147
+ # A list of addresses that are allowed to connect to the munin-node.
148
+ # Add the IP address of your munin-server.
149
+
150
+ set :munin_allow_from_addresses, ["127.0.0.1"]
151
+
152
+ after "deploy:setup",
153
+ "munin_node:configure"
154
+
155
+
140
156
  #############################################################################
141
157
  # Logrotation configuration
142
158
  #############################################################################
@@ -165,6 +181,7 @@ after "deploy:setup",
165
181
  "apache:upload_vhost_config",
166
182
  "db:upload_config_yml",
167
183
  "gems:install"
184
+ "shared:setup"
168
185
 
169
186
  after "deploy:cold",
170
187
  "apache:enable_site",
@@ -0,0 +1,45 @@
1
+ #
2
+ # Example config-file for munin-node
3
+ #
4
+
5
+ log_level 4
6
+ log_file /var/log/munin/munin-node.log
7
+ pid_file /var/run/munin/munin-node.pid
8
+
9
+ background 1
10
+ setseid 1
11
+
12
+ user root
13
+ group root
14
+ setsid yes
15
+
16
+ # Regexps for files to ignore
17
+
18
+ ignore_file ~$
19
+ ignore_file \.bak$
20
+ ignore_file %$
21
+ ignore_file \.dpkg-(tmp|new|old|dist)$
22
+ ignore_file \.rpm(save|new)$
23
+ ignore_file \.pod$
24
+
25
+ # Set this if the client doesn't report the correct hostname when
26
+ # telnetting to localhost, port 4949
27
+ #
28
+ #host_name localhost.localdomain
29
+
30
+ # A list of addresses that are allowed to connect. This must be a
31
+ # regular expression, due to brain damage in Net::Server, which
32
+ # doesn't understand CIDR-style network notation. You may repeat
33
+ # the allow line as many times as you'd like
34
+
35
+ <% for address in fetch(:munin_allow_from_addresses, ['127.0.0.1'] %>
36
+ allow ^<%= address.gsub('.','\.') %>$
37
+ <% end %>
38
+
39
+ # Which address to bind to;
40
+ host *
41
+ # host 127.0.0.1
42
+
43
+ # And which port
44
+ port 4949
45
+
@@ -1,3 +1,3 @@
1
- PassengerRoot /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-<%= passenger_version || "2.2.8" %>
1
+ PassengerRoot /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-<%= passenger_version || "2.2.9" %>
2
2
  PassengerRuby /usr/local/ruby-enterprise/bin/ruby
3
3
  RailsEnv production
@@ -1 +1 @@
1
- LoadModule passenger_module /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-<%= passenger_version || "2.2.8" %>/ext/apache2/mod_passenger.so
1
+ LoadModule passenger_module /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-<%= passenger_version || "2.2.9" %>/ext/apache2/mod_passenger.so
@@ -21,6 +21,8 @@ policy :passenger_stack, :roles => :app do
21
21
  requires :ferm # ferm iptable configuration tool
22
22
  requires :ferm_conf # configure ferm (allow http, https and ssh)
23
23
  requires :monit # monit - system process monitoring
24
+ requires :munin_node # install munin-node for system monitoring
25
+ requires :munin_apache_status # configure extended apache status information
24
26
  end
25
27
 
26
28
  deployment do
@@ -6,9 +6,9 @@
6
6
  DocumentRoot /var/www/rails_apps/<%= application %>/current/public
7
7
 
8
8
  <directory "/var/www/rails_apps/<%= application %>/current/public">
9
+ AllowOverride all # <-- relax Apache security settings
10
+ Options -MultiViews # <-- MultiViews must be turned off
9
11
  Options FollowSymLinks
10
- Order allow,deny
11
- Allow from all
12
12
  </directory>
13
13
  RailsEnv <%= fetch(:rails_env, "production") %>
14
14
  LogLevel warn
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railslove_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bumann
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-17 00:00:00 +01:00
12
+ date: 2010-02-04 00:00:00 +01:00
13
13
  default_executable: deployify
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -48,6 +48,7 @@ files:
48
48
  - lib/railslove/recipes/memcache.rb
49
49
  - lib/railslove/recipes/misc.rb
50
50
  - lib/railslove/recipes/monit.rb
51
+ - lib/railslove/recipes/munin_node.rb
51
52
  - lib/railslove/recipes/passenger.rb
52
53
  - lib/railslove/recipes/shared.rb
53
54
  - lib/railslove/recipes/sphinx.rb
@@ -60,6 +61,7 @@ files:
60
61
  - lib/railslove/sprinkle/image_magick.rb
61
62
  - lib/railslove/sprinkle/memcache.rb
62
63
  - lib/railslove/sprinkle/monit.rb
64
+ - lib/railslove/sprinkle/munin.rb
63
65
  - lib/railslove/sprinkle/mysql.rb
64
66
  - lib/railslove/sprinkle/nginx.rb
65
67
  - lib/railslove/sprinkle/passenger.rb
@@ -82,6 +84,7 @@ files:
82
84
  - lib/railslove/templates/monitoring/sphinx.monit.erb
83
85
  - lib/railslove/templates/monitoring/sshd.monit.erb
84
86
  - lib/railslove/templates/monitrc.erb
87
+ - lib/railslove/templates/munin-node.conf.erb
85
88
  - lib/railslove/templates/nginx.conf
86
89
  - lib/railslove/templates/nginx_init
87
90
  - lib/railslove/templates/passenger.conf