fingercap 0.4.4 → 0.4.5

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.
@@ -8,6 +8,8 @@ Capistrano::Configuration.instance(:must_exist).load do
8
8
  set :domain, 'miller.fngtps.com'
9
9
  set :deploy_to, "/var/www/#{application}"
10
10
 
11
+ set :keep_releases, 2
12
+
11
13
  role :web, domain
12
14
  role :app, domain
13
15
  role :db, domain, :primary => true
@@ -0,0 +1,257 @@
1
+ require 'fingercap/recipes'
2
+ require 'fingercap/persistant_directory'
3
+
4
+ Capistrano::Configuration.instance(:must_exist).load do
5
+ def sudorun(command)
6
+ deploy_password = fetch(:deploy_password, Capistrano::CLI.password_prompt("Password: "))
7
+ run(command) do |channel, stream, output|
8
+ if output =~ /password/
9
+ channel.send_data("#{deploy_password}\n")
10
+ end
11
+ end
12
+ end
13
+
14
+ def _instances
15
+ if ENV['INSTANCE']
16
+ [ENV['INSTANCE']]
17
+ elsif ENV['INSTANCES']
18
+ ENV['INSTANCES'].split(' ')
19
+ elsif variables[:instances_file]
20
+ File.read(File.expand_path(variables[:instances_file], __FILE__)).split(/\s/).map { |i| i.strip }
21
+ else
22
+ puts "[!] Please set an :instances_file or pass the instances to operate on through INSTANCE or INSTANCES."
23
+ exit -1
24
+ end
25
+ end
26
+
27
+ def install_from_secure(path, remote_file_name, options={})
28
+ sudo "scp #{remote_ssh_options} deploy@secure.callrecord.me:/home/deploy/#{path} #{remote_file_name}"
29
+ end
30
+
31
+ set :instances, _instances
32
+ set :primary_instance, instances.first
33
+
34
+ default_run_options[:pty] = true
35
+ default_run_options[:shell] = 'bash -l'
36
+
37
+ set :use_sudo, false
38
+
39
+ # We want /etc/profile and stuff to be read
40
+ # -l => Behave as if we were a login shell
41
+ default_run_options[:shell] = 'bash -l'
42
+
43
+ set :runner, 'app'
44
+ set :user, 'deploy'
45
+ set :deploy_to, "/var/www/#{application}"
46
+
47
+ set :keep_releases, 2
48
+
49
+ set :domain, primary_instance
50
+ role :app, *instances
51
+ role :web, *instances
52
+ role :db, primary_instance, :primary => true
53
+ role :master, primary_instance
54
+
55
+ set :remote_secure_key_file, '/home/deploy/.ssh/secure.key'
56
+ set :remote_ssh_options, "-o 'StrictHostKeyChecking no' -i #{remote_secure_key_file}"
57
+
58
+ if variables[:deploy_key_file]
59
+ if File.exist?(deploy_key_file)
60
+ ssh_options[:keys] = [deploy_key_file]
61
+ else
62
+ puts "[!] Can't read `#{deploy_key_file}', maybe certain volumes aren't mounted?"
63
+ exit -1
64
+ end
65
+ else
66
+ puts "[!] Please set :ssh_key_file with a path to a valid SSH key for the deploy user."
67
+ end
68
+
69
+ namespace :key do
70
+ desc "Push the secure SSH key to the instance"
71
+ task :push do
72
+ remote_secure_key_dir = File.dirname(remote_secure_key_file)
73
+ sudo "mkdir -p #{remote_secure_key_dir}"
74
+ sudo "chown -R deploy:deploy #{remote_secure_key_dir}"
75
+ sudo "rm -f #{remote_secure_key_file}"
76
+ upload(secure_key_file, remote_secure_key_file)
77
+ sudo "chmod 400 #{remote_secure_key_file}"
78
+ end
79
+
80
+ desc "Remove the secure SSH key from the instance"
81
+ task :remove do
82
+ sudo "rm -f #{remote_secure_key_file}"
83
+ end
84
+ end
85
+
86
+ namespace :configure do
87
+ desc "Set permissions on the application install directories"
88
+ task :set_permissions do
89
+ try_sudo "chown -R #{user}:wheel #{deploy_to}"
90
+ try_sudo "chown -R #{fetch(:runner, "app")}:wheel #{shared_path}"
91
+ end
92
+
93
+ desc "Create persistant directories"
94
+ task :create_persistant_directories do
95
+ raise "Overwrite this task for the specific application"
96
+ end
97
+
98
+ desc "Symlink persistant directories"
99
+ task :symlink_persistant_directories do
100
+ raise "Overwrite this task for the specific application"
101
+ end
102
+
103
+ desc "Copy credentials from the secure instance to the shared directory"
104
+ task :install_credentials do
105
+ end
106
+
107
+ desc "Copy server certificates from the secure instance to /etc"
108
+ task :install_certificates do
109
+ # TODO: permissions
110
+ install_from_secure 'etc/ssl/private/robindevices.pem', '/etc/ssl/private/robindevices.pem'
111
+ install_from_secure 'etc/ssl/certs/robin.crt', '/etc/ssl/certs/robin.crt'
112
+ end
113
+
114
+ desc "Install the Gem bundle needed for production"
115
+ task :install_bundle do
116
+ sudo "bundle install --gemfile #{release_path}/Gemfile --without test development"
117
+ end
118
+
119
+ desc "Install all gems needed by the application"
120
+ task :install_gems do
121
+ sudorun "if [ -f #{current_path}/Rakefile ]; then cd #{current_path}; sudo ruby ./Dependencies production; fi"
122
+ end
123
+
124
+ desc "Setup additional networking"
125
+ task :networking do
126
+ end
127
+ end
128
+
129
+ namespace :monit do
130
+ desc "Restart services"
131
+ task :restart do
132
+ sudo "/usr/sbin/monit -c /etc/monitrc restart all"
133
+ end
134
+ end
135
+
136
+ namespace :sphinx do
137
+ desc "Stop Sphinx"
138
+ task :stop, :roles => :master do
139
+ config_file = "#{current_path}/config/production.sphinx.conf"
140
+ sudo "touch #{config_file}"
141
+ sudo "chown app:app #{config_file}"
142
+ sudo "chown app:app #{current_path}/log"
143
+ sudorun "if [ -f #{current_path}/Rakefile ]; then cd #{current_path}; sudo -u app rake thinking_sphinx:stop RAILS_ENV=production; echo 'Yes'; fi"
144
+ end
145
+
146
+ desc "Perform additional configuration for the search daemon"
147
+ task :configure, :roles => :master do
148
+ config_file = "#{current_path}/config/environments/production.rb"
149
+ new_config_file = "#{current_path}/config/environments/production.rb.tmp"
150
+ run "cat #{config_file} | sed 's/ThinkingSphinx\..*//' > #{new_config_file}"
151
+ run "mv #{new_config_file} #{config_file}"
152
+
153
+ config_file = "#{current_path}/config/sphinx.yml"
154
+ new_config_file = "#{current_path}/config/sphinx.yml.tmp"
155
+ run "cat #{config_file} | sed 's/address:.*/address: 0.0.0.0/' > #{new_config_file}"
156
+ run "mv #{new_config_file} #{config_file}"
157
+ end
158
+
159
+ desc "Start the search daemon"
160
+ task :start, :roles => :master do
161
+ config_file = "#{current_path}/config/production.sphinx.conf"
162
+ sudo "touch #{config_file}"
163
+ sudo "chown app:app #{config_file}"
164
+ sudo "chown app:app #{current_path}/log"
165
+ sudorun "if [ -f #{current_path}/Rakefile ]; then cd #{current_path}; sudo -u app rake thinking_sphinx:configure RAILS_ENV=production; echo 'Yes'; fi"
166
+ sudorun "if [ -f #{current_path}/Rakefile ]; then cd #{current_path}; sudo -u app rake thinking_sphinx:start RAILS_ENV=production; echo 'Yes'; fi"
167
+ end
168
+ end
169
+
170
+ namespace :tunnel do
171
+ PID_FILE = '/var/run/ssh-tunnel.pid'
172
+ START_STOP_DAEMON = '/sbin/start-stop-daemon'
173
+ SSH = '/usr/bin/ssh'
174
+
175
+ desc "Setup SSH tunnels to the secure instance"
176
+ task :setup do
177
+ args = "#{remote_ssh_options} -L 35553:localhost:35553 deploy@depot.callrecord.me -N"
178
+ sudo "#{START_STOP_DAEMON} --make-pidfile --pidfile #{PID_FILE} --exec #{SSH} --background --start -- #{args} "
179
+ end
180
+
181
+ desc "Tear SSH tunnels to the secure instance down"
182
+ task :teardown do
183
+ sudorun "if [ -f #{PID_FILE} ]; then sudo #{START_STOP_DAEMON} --pidfile #{PID_FILE} --stop; fi"
184
+ end
185
+
186
+ desc "Stop and start the tunnel"
187
+ task :restart do
188
+ tunnel.teardown
189
+ tunnel.setup
190
+ end
191
+
192
+ desc "Clean out the pidfile left by a crashed SSH tunnel"
193
+ task :cleanup do
194
+ sudo "rm -f #{PID_FILE}"
195
+ end
196
+ end
197
+
198
+ namespace :deploy do
199
+ desc "Stop the application (empty operation)"
200
+ task :stop do
201
+ end
202
+
203
+ desc "Start the application"
204
+ task :start do
205
+ apache.restart
206
+ end
207
+
208
+ desc "Restart the application"
209
+ task :restart do
210
+ passenger.restart
211
+ end
212
+
213
+ desc "Configure the instance for this application and install it"
214
+ task :install do
215
+ setup
216
+ configure.set_permissions
217
+ check
218
+ configure.create_persistant_directories
219
+ key.push
220
+ configure.install_credentials
221
+ configure.install_certificates
222
+ configure.networking
223
+ key.remove
224
+ update
225
+ configure.install_bundle
226
+ end
227
+
228
+ desc "Set the server into maintenance mode"
229
+ task :start_maintenance do
230
+ sudo "a2enmod rewrite"
231
+ sudo "a2dissite manage monitor"
232
+ sudo "a2ensite maintenance"
233
+ sudo "/etc/init.d/apache2 reload"
234
+ end
235
+
236
+ desc "Take the server out of maintenance mode"
237
+ task :stop_maintenance do
238
+ sudo "a2dismod rewrite"
239
+ sudo "a2dissite maintenance"
240
+ sudo "a2ensite manage monitor"
241
+ sudo "/etc/init.d/apache2 reload"
242
+ end
243
+ end
244
+
245
+ after 'deploy:finalize_update', 'configure:install_bundle'
246
+ after 'deploy:symlink', 'configure:symlink_persistant_directories'
247
+
248
+ if variables[:prepare_tasks]
249
+ before "deploy", *prepare_tasks
250
+ before "deploy:migrations", *prepare_tasks
251
+ end
252
+
253
+ if variables[:finalize_tasks]
254
+ after "deploy", *finalize_tasks
255
+ after "deploy:migrations", *finalize_tasks
256
+ end
257
+ end
@@ -2,7 +2,7 @@ Capistrano::Configuration.instance(:must_exist).load do
2
2
  namespace :passenger do
3
3
  desc "Restart the Passenger application process."
4
4
  task :restart do
5
- try_sudo "touch #{current_path}/tmp/restart.txt"
5
+ sudo "touch #{current_path}/tmp/restart.txt"
6
6
  end
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fingercap
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
5
- prerelease: false
4
+ hash: 5
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 4
10
- version: 0.4.4
9
+ - 5
10
+ version: 0.4.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Manfred Stienstra
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-25 00:00:00 +01:00
19
- default_executable:
18
+ date: 2012-07-18 00:00:00 Z
20
19
  dependencies: []
21
20
 
22
21
  description: " Fingercap is a set of recipes and tasks meant for deploying to Fingertips servers.\n"
@@ -32,6 +31,7 @@ files:
32
31
  - lib/fingercap/configurations/ec2.rb
33
32
  - lib/fingercap/configurations/miller.rb
34
33
  - lib/fingercap/configurations/recorder.rb
34
+ - lib/fingercap/configurations/robin.rb
35
35
  - lib/fingercap/persistant_directory.rb
36
36
  - lib/fingercap/recipes/apache.rb
37
37
  - lib/fingercap/recipes/notify.rb
@@ -40,7 +40,6 @@ files:
40
40
  - examples/fingercap.yml
41
41
  - README
42
42
  - LICENSE
43
- has_rdoc: true
44
43
  homepage:
45
44
  licenses: []
46
45
 
@@ -70,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
69
  requirements: []
71
70
 
72
71
  rubyforge_project:
73
- rubygems_version: 1.3.7
72
+ rubygems_version: 1.8.18
74
73
  signing_key:
75
74
  specification_version: 3
76
75
  summary: Fingercap is a set of recipes and tasks meant for deploying to Fingertips servers.