recipiez 0.0.1

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.
@@ -0,0 +1,295 @@
1
+ $LOAD_PATH << File.dirname(__FILE__) + '/../lib'
2
+ require 'basecamp_notifier'
3
+ require 'activecollab_notifier'
4
+
5
+ # A collection of reusable deployment tasks.
6
+ # Hook them into your deploy script with the *after* function.
7
+ # Author: Alastair Brunton
8
+
9
+ namespace :recipiez do
10
+
11
+ desc "generate config file used for db syncing etc"
12
+ task :generate_config do
13
+ if File.exists?('config/recipiez.yml')
14
+ puts "Skipping config generation as one exists"
15
+ else
16
+ `cp vendor/plugins/deployment_recipiez/recipes/templates/recipiez.yml.example config/recipiez.yml`
17
+ end
18
+ end
19
+
20
+
21
+ desc "Rename db file for deployment."
22
+ task :rename_db_file do
23
+ run "cp #{release_path}/config/database.#{rails_env} #{release_path}/config/database.yml"
24
+ end
25
+
26
+ desc "Rename db file for deployment."
27
+ task :rename_settings_file do
28
+ run "cp #{release_path}/config/settings.yml.#{rails_env} #{release_path}/config/settings.yml"
29
+ end
30
+
31
+ # You need to add the below line to your deploy.rb
32
+ # set :basecamp_auth, {:username => 'robot', :domain => 'ifo.projectpath.com',
33
+ # :password => 'robot', :project_id => 828898,
34
+ # :category_id => 15509}
35
+ desc "Update basecamp with information of the deployment."
36
+ task :update_basecamp do
37
+ basecamp_notifier = BasecampNotifier.new(application, rails_env,
38
+ basecamp_auth, current_revision, get_rev_log)
39
+ basecamp_notifier.notify
40
+ end
41
+
42
+ # You need to add the below line to your deploy.rb
43
+ # set :activecollab_options, {:base_url => "http://projects.bla.com",
44
+ # :project_id => 5, :ticket_id => 10,
45
+ # :username => 'bla', :password => 'bla'}
46
+ desc "Update activecollab with information of the deployment."
47
+ task :update_activecollab do
48
+ notifier = ActiveCollab::Notifier.new(activecollab_options)
49
+ notifier.say(get_rev_log)
50
+ end
51
+
52
+ desc "This gets the revision log"
53
+ task :get_rev_log do
54
+ grab_revision_log
55
+ end
56
+
57
+ desc "Restart passenger application instance"
58
+ task :restart_passenger do
59
+ run "touch #{current_release}/tmp/restart.txt"
60
+ end
61
+
62
+
63
+ desc "Restart mongrel."
64
+ task :single_mongrel_restart do
65
+ use_sudo == true ? command = "sudo" : command = "run"
66
+ begin
67
+ eval("#{command} \"mongrel_rails stop -c #{release_path}\"")
68
+ rescue
69
+ puts "**** Error ******: Problem stopping mongrel."
70
+ end
71
+ run "sleep 3"
72
+ eval("#{command} \"mongrel_rails start -c #{release_path} -e #{rails_env} -p #{mongrel_port} -d\"")
73
+ end
74
+
75
+ desc "Stop the nginx webserver."
76
+ task :nginx_stop do
77
+ sudo '/etc/init.d/nginx stop'
78
+ end
79
+
80
+ desc "Start the nginx webserver"
81
+ task :nginx_start do
82
+ sudo '/etc/init.d/nginx start'
83
+ end
84
+
85
+ desc "Restart the nginx webserver"
86
+ task :nginx_restart do
87
+ nginx_stop
88
+ nginx_start
89
+ end
90
+
91
+ desc "Change permissions for apache cgi"
92
+ task :change_public_perms do
93
+ run "chmod -R 755 #{release_path}/public"
94
+ end
95
+
96
+ desc "Restart lighttpd"
97
+ task :lighttpd_restart do
98
+ run "#{lighttpd_ctl_path} restart &"
99
+ end
100
+
101
+
102
+ namespace :db do
103
+
104
+ desc "Dump database, copy it across and restore locally."
105
+ task :pull do
106
+ set_variables_from_yaml
107
+ archive = generate_archive(application)
108
+ filename = get_filename(application)
109
+ cmd = "mysqldump --opt --skip-add-locks -u #{db_user} "
110
+ cmd += " -p#{db_password} "
111
+ cmd += "#{database_to_dump} > #{archive}"
112
+ result = run(cmd)
113
+
114
+ cmd = "rsync -av -e \"ssh -p #{ssh_options[:port]} #{get_identities}\" #{user}@#{roles[:db].servers.first}:#{archive} #{dump_dir}#{filename}"
115
+ puts "running #{cmd}"
116
+ result = system(cmd)
117
+ puts result
118
+ run "rm #{archive}"
119
+
120
+ puts "Restoring db"
121
+ begin
122
+ `mysqladmin -u#{db_local_user} -p#{db_local_password} --force drop #{db_dev}`
123
+ rescue
124
+ # do nothing
125
+ end
126
+ `mysqladmin -u#{db_local_user} -p#{db_local_password} --force create #{db_dev}`
127
+ `cat #{dump_dir}#{get_filename(application)} | mysql -u#{db_local_user} -p#{db_local_password} #{db_dev}`
128
+ puts "All done!"
129
+ end
130
+
131
+ desc "Push up the db"
132
+ task :push do
133
+ set_variables_from_yaml
134
+ filename = get_filename(application)
135
+ cmd = "mysqldump --opt --skip-add-locks -u #{db_local_user} "
136
+ cmd += " -p#{db_local_password} "
137
+ cmd += "#{db_dev} > #{dump_dir}#{filename}"
138
+ puts "Running #{cmd}"
139
+ `#{cmd}`
140
+ put File.read("#{dump_dir}#{filename}"), filename
141
+ logger.debug 'Dropping db'
142
+ begin
143
+ run "mysqladmin -u#{db_user} -p#{db_password} --force drop #{database_to_dump}"
144
+ rescue
145
+ # do nothing
146
+ end
147
+ logger.debug 'Creating db'
148
+ run "mysqladmin -u#{db_user} -p#{db_password} --force create #{database_to_dump}"
149
+ logger.debug 'Restoring db'
150
+ run "cat #{filename} | mysql -u#{db_user} -p#{db_password} #{database_to_dump}"
151
+ run "rm #{filename}"
152
+ end
153
+
154
+
155
+ desc "Create database, user and priviledges NB: Requires db_root_password"
156
+ task :setup do
157
+ set_variables_from_yaml
158
+ sudo "mysqladmin -u root -p#{db_root_password} create #{database_to_dump}"
159
+ run mysql_query("CREATE USER '#{db_user}'@'localhost' IDENTIFIED BY '#{db_password}';")
160
+ grant_sql = "GRANT ALL PRIVILEGES ON #{database_to_dump}.* TO #{db_user}@localhost IDENTIFIED BY '#{db_password}'; FLUSH PRIVILEGES;"
161
+ run mysql_query(grant_sql)
162
+ end
163
+
164
+ end
165
+
166
+ desc "pull db and system files"
167
+ task :pull_remote do
168
+ db::pull
169
+ rsync::pull
170
+ end
171
+
172
+
173
+ namespace :rsync do
174
+
175
+ desc "Rsync the shared system dir"
176
+ task :pull do
177
+ `rsync -av -e \"ssh -p #{ssh_options[:port]} #{get_identities}\" #{user}@#{roles[:db].servers.first}:#{shared_path}/system/ public/system/`
178
+ end
179
+
180
+ desc "Sync up the system directory"
181
+ task :push do
182
+ system "rsync -vrz -e \"ssh -p #{ssh_options[:port]} #{get_identities}\" --exclude='.DS_Store' public/system/ #{user}@#{roles[:db].servers.first}:#{shared_path}/system"
183
+ end
184
+
185
+ end
186
+
187
+ desc "Install bundler"
188
+ task :bundler do
189
+ sudo "gem install bundler --no-rdoc --no-ri"
190
+ end
191
+
192
+ desc "Install libxml and headers"
193
+ task :libxml do
194
+ sudo "apt-get install -y libxml2 libxml2-dev libxslt1-dev"
195
+ end
196
+
197
+
198
+ desc "Setup /var/www/apps"
199
+ task :app_dir do
200
+ sudo <<-CMD
201
+ if [ ! -d "/var/www/apps" ]; then
202
+ sudo mkdir -p /var/www/apps
203
+ fi
204
+ CMD
205
+ sudo "chown -R #{user}:#{user} /var/www/apps"
206
+ end
207
+
208
+ desc "Add user to www-data group"
209
+ task :www_group do
210
+ sudo "sudo usermod -a -G www-data #{user}"
211
+ sudo "sudo usermod -a -G #{user} www-data"
212
+ end
213
+
214
+ desc "Setup the deployment directories and fix permissions"
215
+ task :setup do
216
+ deploy::setup
217
+ sudo "chown -R #{user}:#{user} #{deploy_to}"
218
+ end
219
+
220
+ end
221
+
222
+ namespace :deploy do
223
+ task :restart do
224
+ # override this task
225
+ end
226
+ end
227
+
228
+ # Internal helper to shell out and run a query. Doesn't select a database.
229
+ def mysql_query(sql)
230
+ "/usr/bin/mysql -u root -p#{db_root_password} -e \"#{sql}\""
231
+ end
232
+
233
+
234
+
235
+ def generate_archive(name)
236
+ '/tmp/' + get_filename(name)
237
+ end
238
+
239
+ def get_filename(name)
240
+ name.sub('_', '.') + '.sql'
241
+ end
242
+
243
+
244
+ def grab_revision_log
245
+ case scm.to_sym
246
+ when :git
247
+ %x( git log --pretty=format:"* #{"[%h, %an] %s"}" #{previous_revision}..#{current_revision} )
248
+ when :subversion
249
+ format_svn_log current_revision, previous_revision
250
+ end
251
+ end
252
+
253
+ def get_identities
254
+ op = ''
255
+ if ssh_options[:keys] && ssh_options[:keys].any?
256
+ ssh_options[:keys].each do |priv_key|
257
+ if File.exists?(priv_key)
258
+ op += "-i #{priv_key} "
259
+ end
260
+ end
261
+ end
262
+ op
263
+ end
264
+
265
+ # Using REXML as it comes bundled with Ruby, would love to use Hpricot.
266
+ # <logentry revision="2176">
267
+ # <author>jgoebel</author>
268
+ # <date>2006-09-17T02:38:48.040529Z</date>
269
+ # <msg>add delete link</msg>
270
+ # </logentry>
271
+ def format_svn_log(current_revision, previous_revision)
272
+ require 'rexml/document'
273
+ begin
274
+ xml = REXML::Document.new(%x( svn log --xml --revision #{current_revision}:#{previous_revision} ))
275
+ xml.elements.collect('//logentry') do |logentry|
276
+ "* [#{logentry.attributes['revision']}, #{logentry.elements['author'].text}] #{logentry.elements['msg'].text}"
277
+ end.join("\n")
278
+ rescue
279
+ %x( svn log --revision #{current_revision}:#{previous_revision} )
280
+ end
281
+ end
282
+
283
+
284
+ def set_variables_from_yaml
285
+
286
+ unless File.exists?("config/recipiez.yml")
287
+ raise StandardError, "You need a config/recipiez.yml file which defines the database syncing settings. Run recipiez:generate_config"
288
+ end
289
+
290
+ global = YAML.load_file("config/recipiez.yml")
291
+ app_config = global[rails_env]
292
+ app_config.each_pair do |key, value|
293
+ set key.to_sym, value
294
+ end
295
+ end
@@ -0,0 +1,9 @@
1
+ namespace :logrotate do
2
+ desc "Configures logrotate for the application"
3
+ task :configure, :roles => :app do
4
+ generated = render('logrotate', binding)
5
+ puts generated
6
+ put generated, "#{application}"
7
+ sudo "mv #{application} /etc/logrotate.d/#{application}"
8
+ end
9
+ end
data/recipes/monit.rb ADDED
@@ -0,0 +1,46 @@
1
+ namespace :monit do
2
+
3
+ desc "configures monit for nginx"
4
+ task :nginx, :roles => :web do
5
+ put render('nginx_monit', binding), "nginx.conf"
6
+ sudo "mv nginx.conf /etc/monit/conf.d/nginx.conf"
7
+ sudo "/etc/init.d/monit restart"
8
+ end
9
+
10
+ desc "configures monit for thin"
11
+ task :thin, :roles => :web do
12
+ put render('thin_monit', binding), "#{application}.conf"
13
+ sudo "mv #{application}.conf /etc/monit/conf.d/#{application}.conf"
14
+ sudo "/etc/init.d/monit restart"
15
+ end
16
+
17
+ desc "configures monit for apache"
18
+ task :apache, :roles => :web do
19
+ put render('apache_monit', binding), "apache_monit.conf"
20
+ sudo "mv apache_monit.conf /etc/monit/conf.d/apache_monit.conf"
21
+ sudo "/etc/init.d/monit restart"
22
+ end
23
+
24
+ desc "configures monit for mysql"
25
+ task :mysql, :roles => :db do
26
+ put render("mysql_monit", binding), "mysql_monit.conf"
27
+ sudo "mv mysql_monit.conf /etc/monit/conf.d/mysql_monit.conf"
28
+ sudo "/etc/init.d/monit restart"
29
+ end
30
+
31
+ desc "configures monit for mysql"
32
+ task :sshd, :roles => :web do
33
+ put render("sshd_monit", binding), "sshd_monit.conf"
34
+ sudo "mv sshd_monit.conf /etc/monit/conf.d/sshd_monit.conf"
35
+ sudo "/etc/init.d/monit restart"
36
+ end
37
+
38
+ task :configure, :roles => :web do
39
+ put render("monit_config", binding), 'monitrc'
40
+ sudo "mv monitrc /etc/monit/monitrc"
41
+ sudo "chown root:root /etc/monit/monitrc"
42
+ sudo "/etc/init.d/monit restart"
43
+ end
44
+
45
+
46
+ end
data/recipes/nginx.rb ADDED
@@ -0,0 +1,35 @@
1
+ namespace :nginx do
2
+ desc "configures a vhost for the app, needs - num_servers, start_port"
3
+ task :configure, :roles => :web do
4
+ put render("nginx_vhost", binding), "#{application}.conf"
5
+ sudo "mv #{application}.conf /etc/nginx/sites-available/#{application}.conf"
6
+ begin
7
+ sudo "ln -s /etc/nginx/sites-available/#{application}.conf /etc/nginx/sites-enabled/#{application}.conf"
8
+ rescue
9
+ # do nothing
10
+ end
11
+
12
+ begin
13
+ stop
14
+ rescue
15
+ # do nothing
16
+ end
17
+
18
+ begin
19
+ start
20
+ rescue
21
+ # do nothing
22
+ end
23
+ end
24
+
25
+ desc "Starts Nginx webserver"
26
+ task :start, :roles => :web do
27
+ sudo "/etc/init.d/nginx start"
28
+ end
29
+
30
+ desc "Stops Nginx webserver"
31
+ task :stop, :roles => :web do
32
+ sudo "/etc/init.d/nginx stop"
33
+ end
34
+
35
+ end
data/recipes/render.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'erb'
2
+
3
+ def render(file, binding)
4
+ template = File.read("#{File.dirname(__FILE__)}/templates/#{file}.erb")
5
+ result = ERB.new(template).result(binding)
6
+ end
@@ -0,0 +1,11 @@
1
+ check process httpd with pidfile /var/run/apache2.pid
2
+ group www-data
3
+ start program "/etc/init.d/apache2 start"
4
+ stop program "/etc/init.d/apache2 stop"
5
+ if failed host localhost port 80 protocol http
6
+ and request "/" then alert
7
+ if cpu is greater than 60% for 2 cycles then alert
8
+ if cpu > 80% for 5 cycles then restart
9
+ if children > 250 then restart
10
+ if loadavg(5min) greater than 10 for 8 cycles then alert
11
+ if 3 restarts within 5 cycles then timeout
@@ -0,0 +1,9 @@
1
+ <%= current_path %>/log/*.log {
2
+ daily
3
+ missingok
4
+ rotate 14
5
+ compress
6
+ delaycompress
7
+ notifempty
8
+ copytruncate
9
+ }
@@ -0,0 +1,7 @@
1
+ set daemon 60
2
+ set logfile syslog facility log_daemon
3
+ set mailserver localhost
4
+ set mail-format { from: <%= monit_from_address %> }
5
+ set alert <%= monit_alert_address %>
6
+
7
+ include /etc/monit/conf.d/*
@@ -0,0 +1,6 @@
1
+ check process mysql with pidfile /var/run/mysqld/mysqld.pid
2
+ group database
3
+ start program = "/etc/init.d/mysql start"
4
+ stop program = "/etc/init.d/mysql stop"
5
+ if failed host 127.0.0.1 port 3306 then restart
6
+ if 5 restarts within 5 cycles then timeout
@@ -0,0 +1,9 @@
1
+ # nginx
2
+ check process nginx with pidfile /var/run/nginx.pid
3
+ start program = "/etc/init.d/nginx start"
4
+ stop program = "/etc/init.d/nginx stop"
5
+ if failed host 127.0.0.1 port <%= web_port ? web_port : 80 %> then restart
6
+ if cpu is greater than 40% for 2 cycles then alert
7
+ if cpu > 80% for 5 cycles then restart
8
+ if 10 restarts within 10 cycles then timeout
9
+ group www
@@ -0,0 +1,135 @@
1
+ upstream <%= application %> {
2
+ <% i = 0 %>
3
+ <% num_servers.times do %>
4
+ server 127.0.0.1:<%= start_port.to_i + i %>;
5
+ <% i += 1 %>
6
+ <% end %>
7
+ }
8
+
9
+ server {
10
+
11
+ listen <%= web_port ? web_port : 80 %>;
12
+ server_name www.<%= domain %>;
13
+ rewrite ^(.*) http://<%= domain %>$1 permanent;
14
+ }
15
+
16
+
17
+ server {
18
+
19
+ listen <%= web_port ? web_port : 80 %>;
20
+ server_name <%= domain %>;
21
+
22
+ access_log <%= current_path %>/log/access.log;
23
+ error_log <%= current_path %>/log/error.log;
24
+
25
+ root <%= current_path %>/public/;
26
+ index index.html;
27
+ client_max_body_size 50M;
28
+
29
+ # this rewrites all the requests to the maintenance.html
30
+ # page if it exists in the doc root. This is for capistrano's
31
+ # disable web task
32
+ if (-f $document_root/maintenance.html) {
33
+ rewrite ^(.*)$ /maintenance.html last;
34
+ break;
35
+ }
36
+
37
+
38
+ location / {
39
+ proxy_set_header X-Real-IP $remote_addr;
40
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
41
+ proxy_set_header Host $http_host;
42
+ proxy_redirect off;
43
+ proxy_max_temp_file_size 0;
44
+
45
+ # If the file exists as a static file serve it directly without
46
+ # running all the other rewrite tests on it
47
+ if (-f $request_filename) {
48
+ break;
49
+ }
50
+
51
+ if (-f $request_filename/index.html) {
52
+ rewrite (.*) $1/index.html break;
53
+ }
54
+
55
+ if (-f $request_filename.html) {
56
+ rewrite (.*) $1.html break;
57
+ }
58
+
59
+ if (!-f $request_filename) {
60
+ proxy_pass http://<%= application %>;
61
+ break;
62
+ }
63
+ }
64
+
65
+ error_page 500 502 503 504 /50x.html;
66
+ location = /50x.html {
67
+ root html;
68
+ }
69
+
70
+ }
71
+
72
+
73
+ <% if ssl && ssl == 'on' %>
74
+ server {
75
+ listen 443;
76
+ ssl on;
77
+
78
+ ssl_certificate <%= ssl_cert %>;
79
+ ssl_certificate_key <%= ssl_key %>;
80
+
81
+
82
+ access_log <%= current_path %>/log/access.log;
83
+ error_log <%= current_path %>/log/error.log;
84
+
85
+ root <%= current_path %>/public/;
86
+ index index.html;
87
+ client_max_body_size 50M;
88
+
89
+
90
+ # this rewrites all the requests to the maintenance.html
91
+ # page if it exists in the doc root. This is for capistrano's
92
+ # disable web task
93
+ if (-f $document_root/maintenance.html) {
94
+ rewrite ^(.*)$ /maintenance.html last;
95
+ break;
96
+ }
97
+
98
+
99
+
100
+ location / {
101
+ proxy_set_header X-Real-IP $remote_addr;
102
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
103
+ proxy_set_header Host $http_host;
104
+ proxy_redirect off;
105
+ proxy_set_header X-FORWARDED_PROTO https;
106
+ proxy_max_temp_file_size 0;
107
+
108
+ # If the file exists as a static file serve it directly without
109
+ # running all the other rewrite tests on it
110
+ if (-f $request_filename) {
111
+ break;
112
+ }
113
+
114
+ if (-f $request_filename/index.html) {
115
+ rewrite (.*) $1/index.html break;
116
+ }
117
+
118
+ if (-f $request_filename.html) {
119
+ rewrite (.*) $1.html break;
120
+ }
121
+
122
+ if (!-f $request_filename) {
123
+ proxy_pass http://<%= application %>;
124
+ break;
125
+ }
126
+ }
127
+
128
+ error_page 500 502 503 504 /50x.html;
129
+ location = /50x.html {
130
+ root html;
131
+ }
132
+
133
+ }
134
+ <% end %>
135
+
@@ -0,0 +1,13 @@
1
+ <VirtualHost *:80>
2
+ ServerName <%= app_domain %>
3
+ ServerAlias www.<%= app_domain %>
4
+
5
+ DocumentRoot <%= deploy_to %>/current/public
6
+ RailsEnv <%= rails_env %>
7
+
8
+ <Directory <%= deploy_to %>/current/public>
9
+ AllowOverride all
10
+ Options -MultiViews
11
+ </Directory>
12
+
13
+ </VirtualHost>
@@ -0,0 +1 @@
1
+ AddHandler application/x-httpd-php .php
@@ -0,0 +1,12 @@
1
+ <VirtualHost *:<%= apache_port %>>
2
+ ServerName <%= app_domain %>
3
+ ServerAlias www.<%= app_domain %>
4
+
5
+ DocumentRoot <%= deploy_to %>/current/public
6
+
7
+ <Directory <%= deploy_to %>/current/public>
8
+ AllowOverride all
9
+ Options -MultiViews
10
+ </Directory>
11
+
12
+ </VirtualHost>
@@ -0,0 +1,8 @@
1
+ production:
2
+ db_user: root
3
+ db_password: password
4
+ db_local_user: root
5
+ db_local_password: password
6
+ dump_dir: /tmp/
7
+ database_to_dump: dbname_production
8
+ db_dev: dbname_development
@@ -0,0 +1,5 @@
1
+ check process sshd with pidfile /var/run/sshd.pid
2
+ start program "/etc/init.d/ssh start"
3
+ stop program "/etc/init.d/ssh stop"
4
+ if failed port <%= ssh_options[:port] %> protocol ssh then restart
5
+ if 5 restarts within 5 cycles then timeout
@@ -0,0 +1,16 @@
1
+ <% i = 0 %>
2
+ <% start_port.upto(start_port + (num_servers - 1)) do |port| %>
3
+
4
+ check process <%= application %>_<%= port %>
5
+ with pidfile <%= shared_path %>/pids/thin.<%= port %>.pid
6
+ start program = "/usr/bin/ruby /usr/bin/thin start -C /etc/thin/<%= application %>.yml --only <%= i %>"
7
+ stop program = "/usr/bin/ruby /usr/bin/thin stop -C /etc/thin/<%= application %>.yml --only <%= i %>"
8
+ if totalmem > 120.0 MB for 5 cycles then restart
9
+ if failed port <%= port %> then restart
10
+ if cpu usage > 95% for 3 cycles then restart
11
+ if 5 restarts within 5 cycles then timeout
12
+ if failed host 127.0.0.1 port <%= port %> protocol http
13
+ and request "/" then alert
14
+ group <%= application %>
15
+ <% i += 1 %>
16
+ <% end %>
data/recipes/thin.rb ADDED
@@ -0,0 +1,37 @@
1
+ namespace :thin do
2
+
3
+ desc "configures thin, requires num_servers and start_port"
4
+ task :configure, :roles => :app do
5
+ sudo "thin config -C /etc/thin/#{application}.yml -c #{current_path} --servers #{num_servers} -e #{rails_env} --port #{start_port}"
6
+ end
7
+
8
+ desc "configures thin with rackup eg. Sinatra. Requires thin_port, rack_env"
9
+ task :configure_rack, :roles => :app do
10
+ sudo "thin config -C /etc/thin/#{application}.yml -c #{current_path} --servers #{num_servers} --port #{start_port} -e #{rack_env} -R #{current_path}/config.ru"
11
+ end
12
+
13
+ desc "install thin"
14
+ task :install, :roles => :app do
15
+ sudo "gem install thin"
16
+ sudo "thin install"
17
+ sudo "/usr/sbin/update-rc.d -f thin defaults"
18
+ end
19
+
20
+ desc "start thin"
21
+ task :start, :roles => :app do
22
+ sudo "/etc/init.d/thin start"
23
+ sudo "/usr/bin/ruby /usr/bin/thin start -C /etc/thin/#{application}.yml"
24
+ end
25
+
26
+ desc "stop thin"
27
+ task :stop, :roles => :app do
28
+ sudo "/usr/bin/ruby /usr/bin/thin stop -C /etc/thin/#{application}.yml"
29
+ end
30
+
31
+ desc "restart thin"
32
+ task :restart, :roles => :app do
33
+ sudo "/usr/bin/ruby /usr/bin/thin restart -C /etc/thin/#{application}.yml"
34
+ end
35
+
36
+
37
+ end