handy 0.0.11 → 0.0.12

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,21 @@
1
+ namespace :delayed_job do
2
+ desc "Start delayed_job process"
3
+ task :start, :roles => :app do
4
+ run "cd #{current_path}; RAILS_ENV=#{stage} script/delayed_job start"
5
+ end
6
+
7
+ desc "Stop delayed_job process"
8
+ task :stop, :roles => :app do
9
+ run "cd #{current_path}; RAILS_ENV=#{stage} script/delayed_job stop"
10
+ end
11
+
12
+ desc "Restart delayed_job process"
13
+ task :restart, :roles => :app do
14
+ run "cd #{current_path}; RAILS_ENV=#{stage} script/delayed_job restart"
15
+ end
16
+ end
17
+
18
+ after "deploy:start", "delayed_job:start"
19
+ after "deploy:stop", "delayed_job:stop"
20
+ after "deploy:restart", "delayed_job:restart"
21
+
@@ -0,0 +1,33 @@
1
+ # Usage:
2
+ #
3
+ # cap production remote 'tail -f log/production.log'
4
+ # cap production rake 'db:prod2staging'
5
+
6
+ set :sudo_call, ''
7
+
8
+ desc 'makes remote/rake calls to be executed with sudo'
9
+ task :use_sudo do
10
+ set :sudo_call, 'sudo'
11
+ end
12
+
13
+ desc 'run rake task'
14
+ task :rake do
15
+ ARGV.values_at(Range.new(ARGV.index('rake')+1,-1)).each do |task|
16
+ run "cd #{current_path}; #{sudo_call} RAILS_ENV=#{stage} rake #{task}"
17
+ end
18
+ exit(0)
19
+ end
20
+
21
+ desc 'run remote command'
22
+ task :remote do
23
+ command=ARGV.values_at(Range.new(ARGV.index('remote')+1, -1))
24
+ run "cd #{current_path}; #{sudo_call} RAILS_ENV=#{stage} #{command*' '}"
25
+ exit(0)
26
+ end
27
+
28
+ desc 'run specified rails code on server'
29
+ task :runner do
30
+ command=ARGV.values_at(Range.new(ARGV.index('runner')+1, -1))
31
+ run "cd #{current_path}; RAILS_ENV=#{stage} rails runner '#{command*' '}'"
32
+ exit(0)
33
+ end
@@ -0,0 +1,17 @@
1
+ # source: http://tomcopeland.blogs.com/juniordeveloper/2008/05/mod_rails-and-c.html
2
+ namespace :deploy do
3
+ desc "Restarting mod_rails with restart.txt"
4
+ task :restart, :roles => :app, :except => { :no_release => true } do
5
+ run "touch #{current_path}/tmp/restart.txt"
6
+ end
7
+
8
+ [:start, :stop].each do |t|
9
+ desc "#{t} task is a no-op with mod_rails"
10
+ task t, :roles => :app do ; end
11
+ end
12
+
13
+ desc "invoke the db migration"
14
+ task:migrate, :roles => :app do
15
+ send(run_method, "cd #{current_path} && rake db:migrate RAILS_ENV=#{stage} ")
16
+ end
17
+ end
@@ -0,0 +1,14 @@
1
+ # Usage:
2
+ #
3
+ # Following capistrano task will restore your local database with database from remote database
4
+ # cap production db:restore_local
5
+ namespace :db do
6
+ desc 'restore local file with data from remote machine'
7
+ task :restore_local do
8
+ timestamp = Time.now.strftime("%Y-%m-%d-%H-%M-%S")
9
+ send(run_method, "cd #{current_path} && rake handy:db:backup timestamp=#{timestamp} RAILS_ENV=#{stage} ")
10
+ get "#{deploy_to}/current/tmp/#{timestamp}.sql.gz","tmp/#{timestamp}.sql.gz"
11
+ system("rake handy:db:restore file='#{timestamp}.sql.gz'")
12
+ end
13
+ end
14
+
data/lib/handy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Handy
2
- VERSION = '0.0.11'
2
+ VERSION = '0.0.12'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: handy
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 11
10
- version: 0.0.11
9
+ - 12
10
+ version: 0.0.12
11
11
  platform: ruby
12
12
  authors:
13
13
  - Neeraj Singh
@@ -65,6 +65,10 @@ files:
65
65
  - Rakefile
66
66
  - lib/handy.rb
67
67
  - lib/handy/backup.rb
68
+ - lib/handy/capistrano/delayed_job.rb
69
+ - lib/handy/capistrano/remote_tasks.rb
70
+ - lib/handy/capistrano/restart.rb
71
+ - lib/handy/capistrano/restore_local.rb
68
72
  - lib/handy/capistrano/user_confirmation.rb
69
73
  - lib/handy/db2db.rb
70
74
  - lib/handy/dump2s3.rb