remoting 0.2.14 → 0.2.16

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -116,20 +116,18 @@ task :reload do
116
116
  end
117
117
  ```
118
118
 
119
- ## A note on modularity
119
+ ## Recipes
120
120
 
121
121
  A complete deployment manager (like Capistrano even if probably not as good as it is) can be easily built over *remoting*. Capistrano recipes can be ordinary rake tasks packed as gems. Plus various _deployment strategies_ can be assembled as dependencies of a main `deploy` task.
122
122
 
123
- ``` rb
124
- # Gemfile
125
- gem 'remoting_scm_git' # provides 'remoting:scm:push, remoting:scm:update_remoting_code'
126
- gem 'remoting_server_passenger' # provides 'remoting:server:restart'
123
+ As from version `0.3.0` **Remoting** added support for recipes with a generator (`rails g remoting:recipe`) that basically installs recipes from [remoting/recipes](https://github.com/mcasimir/remoting/tree/master/recipes) into `lib/tasks/remote`.
124
+
125
+ eg.
127
126
 
128
- # remoting.rake
129
- desc "Deploy application on server"
130
- task :deploy => ["remoting:scm:push", "remoting:scm:update_remoting_code", "remoting:bundle", "remoting:server:restart"] do
131
- end
132
127
  ```
128
+ rails g remoting:recipe rails git bare apache slow_assets_workaround
129
+ ```
130
+
133
131
 
134
132
  ## Examples
135
133
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.14
1
+ 0.2.16
data/examples/remote.rake CHANGED
@@ -5,7 +5,8 @@ namespace :remote do
5
5
 
6
6
  remote('info', config.login) do
7
7
  source "~/.profile"
8
- source "$HOME/.rvm/scripts/rvm"
8
+ source "/usr/local/rvm/scripts/rvm"
9
+
9
10
 
10
11
  which :ruby
11
12
  echo "RUBY VERSION: `ruby --version`"
@@ -94,7 +95,8 @@ namespace :remote do
94
95
 
95
96
  remote('bundle', config.login) do
96
97
  source "~/.profile"
97
- source "$HOME/.rvm/scripts/rvm"
98
+ source "/usr/local/rvm/scripts/rvm"
99
+
98
100
  rvm :use, config.ruby
99
101
 
100
102
  cd config.dest
@@ -15,6 +15,22 @@ remote:
15
15
  create_file "config/remote.yml", stub
16
16
 
17
17
  end
18
+
19
+ def create_remote_rake
20
+
21
+ create_file "lib/tasks/remote.rake", <<-eos
22
+ namespace :remote do
23
+ desc "Deploy application on server"
24
+ task :deploy => [:push, :bundle, :"assets:compile", :restart] do
25
+ end
26
+ end
27
+
28
+ eos
29
+
30
+
31
+ end
32
+
33
+
18
34
  end
19
35
  end
20
36
  end
@@ -0,0 +1,14 @@
1
+ module Remoting
2
+ class Recipe < Rails::Generators::Base
3
+ source_root File.expand_path('../../../../recipes', __FILE__)
4
+
5
+ argument :names, :as => :array, :required => true, :banner => "RECIPE1 RECIPE2 ..."
6
+
7
+ def install_recipe
8
+ names.each {|name|
9
+ template "#{name}.rake", Rails.root.join("lib", "tasks", "remote", "#{name}.rake")
10
+ }
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,30 @@
1
+ namespace :remote do
2
+ desc "Restart the server"
3
+ task :restart do
4
+ require 'remoting/task'
5
+
6
+ remote('restart', config.login) do
7
+ mkdir '-p', config.dest.join('tmp')
8
+ touch config.dest.join('tmp', 'restart.txt')
9
+ end
10
+
11
+ end
12
+
13
+ namespace :apache do
14
+ task :ensite do
15
+ require 'remoting/task'
16
+ remote('ensite', config.login, :interactive => true) do
17
+ cd "/etc/apache2/sites-enabled"
18
+ sudo "ln -s #{config.dest.join('config', 'apache.conf')} #{config.app}"
19
+ end
20
+ end
21
+
22
+ task :reload do
23
+ require 'remoting/task'
24
+
25
+ remote('reload', config.login, :interactive => true) do
26
+ sudo "/etc/init.d/apache2 reload"
27
+ end
28
+ end
29
+ end
30
+ end
data/recipes/bare.rake ADDED
@@ -0,0 +1,25 @@
1
+ namespace :remote do
2
+ namespace :bare do
3
+
4
+ desc "Initialize a bare git remote"
5
+ task :setup do
6
+ require 'remoting/task'
7
+ repo_location = config.repo.gsub(/^ssh:\/\/[^\/]+/, "")
8
+ remote('setup', config.login) do
9
+ mkdir "-p", repo_location
10
+ cd repo_location
11
+ git :init, "--bare"
12
+ git "--bare", "update-server-info"
13
+ mkdir "-p", config.dest
14
+ git :config, "core.bare", :false
15
+ git :config, "core.worktree", config.dest
16
+ git :config, "receive.denycurrentbranch", :ignore
17
+ touch "hooks/post-receive"
18
+ command("echo '#!/bin/sh' >> hooks/post-receive")
19
+ command("echo git checkout -f >> hooks/post-receive ")
20
+ chmod "+x", "hooks/post-receive"
21
+ end
22
+ end
23
+
24
+ end
25
+ end
data/recipes/git.rake ADDED
@@ -0,0 +1,36 @@
1
+ namespace :remote do
2
+
3
+ desc "Commit everything to remote git repository"
4
+ task :push do
5
+ require 'remoting/task'
6
+
7
+ message = ENV["MESSAGE"] || "commit #{Time.now}"
8
+
9
+ local('push') do
10
+ git :add, "."
11
+ git :commit, "-a", "-m", "\"#{message}\""
12
+ git :push, "origin", "+master:refs/heads/master"
13
+ end
14
+ end
15
+
16
+ desc "Setup git origin"
17
+ task :init do
18
+ require 'remoting/task'
19
+
20
+ local('init') do
21
+ git :init
22
+ git :remote, :add, :origin, config.repo
23
+ end
24
+ end
25
+
26
+ desc "Grab changes from remote git repository"
27
+ task :pull do
28
+ require 'remoting/task'
29
+
30
+ local('pull') do
31
+ git :pull, :origin, :master
32
+ end
33
+ end
34
+
35
+
36
+ end
@@ -0,0 +1,23 @@
1
+ namespace :remote do
2
+ namespace :assets do
3
+
4
+ desc 'Precompile assets'
5
+ task :compile do
6
+ require 'remoting/task'
7
+
8
+ remote('rake assets:precompile', config.login) do
9
+ source "/usr/local/rvm/scripts/rvm"
10
+ rvm :use, config.ruby
11
+ cd config.dest
12
+ command("RAILS_ENV=production bundle exec rake assets:precompile")
13
+ echo 'restarting ...'
14
+ mkdir '-p', config.dest.join('tmp')
15
+ touch config.dest.join('tmp', 'restart.txt')
16
+
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+
23
+
@@ -0,0 +1,126 @@
1
+ namespace :remote do
2
+
3
+ desc "Run bundle install on the server"
4
+ task :bundle do
5
+ require 'remoting/task'
6
+
7
+ remote('bundle', config.login) do
8
+ source "/usr/local/rvm/scripts/rvm"
9
+ rvm :use, config.ruby
10
+
11
+ cd config.dest
12
+ export "LANG=en_US.UTF-8"
13
+ command "RAILS_ENV=production", "bundle install", "--without development test", "--deployment"
14
+ end
15
+ end
16
+
17
+ desc "Run rake tasks on server"
18
+ task :rake, [:invocation] do |t, args|
19
+ require 'remoting/task'
20
+
21
+ invocation = args[:invocation]
22
+
23
+ remote('rake', config.login, :interactive => true) do
24
+ source "/usr/local/rvm/scripts/rvm"
25
+ rvm :use, config.ruby
26
+ cd config.dest
27
+ command("RAILS_ENV=production bundle exec rake #{invocation}")
28
+ end
29
+
30
+ end
31
+
32
+
33
+ desc "Dump a remote logfile"
34
+ task :log, [:lines, :filename] do |t, args|
35
+ require 'remoting/task'
36
+
37
+ filename, lines = args.values_at(:lines, :filename)
38
+ filename ||= "production"
39
+ filename = "#{filename}.log" unless filename =~ /\.[a-z]+$/
40
+
41
+ lines ||= 100
42
+
43
+ remote('log', config.login) do
44
+ cd config.dest
45
+ tail "-#{lines} log/#{filename}"
46
+ end
47
+ end
48
+
49
+ task :logs => [:log] do
50
+ end
51
+
52
+
53
+ desc "Run tail -f on logfile"
54
+ task :logtail, [:filename] do |t, args|
55
+ require 'remoting/task'
56
+
57
+ filename= args[:filename]
58
+ filename ||= "production"
59
+ filename = "#{filename}.log" unless filename =~ /\.[a-z]+$/
60
+
61
+ remote('logtail', config.login) do
62
+ cd config.dest
63
+ tail "-f log/#{filename}"
64
+ end
65
+ end
66
+
67
+ desc "Open a remote console"
68
+ task :console do
69
+ require 'remoting/task'
70
+
71
+ remote('console', config.login, :interactive => true) do
72
+ cd config.dest
73
+ source "/usr/local/rvm/scripts/rvm"
74
+ bundle :exec, "rails c production"
75
+ end
76
+ end
77
+
78
+ namespace :db do
79
+ desc "Migrate remote database"
80
+ task :migrate do |t, args|
81
+ require 'remoting/task'
82
+
83
+ remote('rake db:migrate', config.login) do
84
+ source "/usr/local/rvm/scripts/rvm"
85
+ rvm :use, config.ruby
86
+ cd config.dest
87
+ command("RAILS_ENV=production bundle exec rake db:migrate")
88
+ end
89
+ end
90
+
91
+ desc "Seed remote database"
92
+ task :seed do |t, args|
93
+ require 'remoting/task'
94
+
95
+ remote('rake db:seed', config.login) do
96
+ source "/usr/local/rvm/scripts/rvm"
97
+ rvm :use, config.ruby
98
+ cd config.dest
99
+ command("RAILS_ENV=production bundle exec rake db:seed")
100
+ end
101
+ end
102
+ end
103
+
104
+
105
+ namespace :assets do
106
+
107
+ desc 'Precompile assets'
108
+ task :precompile do
109
+ require 'remoting/task'
110
+
111
+ remote('rake assets:precompile', config.login) do
112
+ source "/usr/local/rvm/scripts/rvm"
113
+ rvm :use, config.ruby
114
+ cd config.dest
115
+ command("RAILS_ENV=production bundle exec rake assets:precompile")
116
+ echo 'restarting ...'
117
+ mkdir '-p', config.dest.join('tmp')
118
+ touch config.dest.join('tmp', 'restart.txt')
119
+
120
+ end
121
+ end
122
+
123
+ end
124
+
125
+
126
+ end
@@ -0,0 +1,18 @@
1
+ namespace :remote do
2
+ namespace :assets do
3
+
4
+ desc 'remoting support for rails-slow-assets-workaround'
5
+ task :compile do
6
+ require 'rails-slow-assets-workaround'
7
+ require 'remoting/task'
8
+
9
+ remote('rake assets:compile', config.login) do
10
+ source "/usr/local/rvm/scripts/rvm"
11
+ rvm :use, config.ruby
12
+ cd config.dest
13
+ command("RAILS_ENV=production bundle exec rake assets:compile")
14
+ end
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,24 @@
1
+ namespace :remote do
2
+
3
+ desc "Dump some remote environment info"
4
+ task :info do
5
+ require 'remoting/task'
6
+ remote('info', config.login) do
7
+
8
+ source "/usr/local/rvm/scripts/rvm"
9
+ which :ruby
10
+ echo "RUBY VERSION: `ruby --version`"
11
+ echo "RUBYGEM VERSION: `gem --version`"
12
+ command "RVM_VER=`rvm --version`"
13
+ echo "RVM VERSION: $RVM_VER"
14
+ end
15
+ end
16
+
17
+ desc "Open a remote shell session on server"
18
+ task :ssh do
19
+ require 'remoting/task'
20
+ remote('ssh', config.login, :interactive => true) do
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,11 @@
1
+ namespace :remote do
2
+ desc "Update crontab with whenever schedule"
3
+ task :whenever do
4
+ require 'remoting/task'
5
+
6
+ remote('whenever', config.login) do
7
+ cd config.dest
8
+ whenever "-w"
9
+ end
10
+ end
11
+ end
data/remoting.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "remoting"
8
- s.version = "0.2.14"
8
+ s.version = "0.2.16"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["mcasimir"]
12
- s.date = "2012-06-23"
12
+ s.date = "2012-08-05"
13
13
  s.description = "Remoting is a great way to turn plain rake tasks in scripts to administer the server remote. It provides a little framework to run remote commands over SSH along with a DSL to define remote scripts."
14
14
  s.email = "maurizio.cas@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
26
26
  "examples/remote.rake",
27
27
  "examples/remote.yml",
28
28
  "lib/generators/remoting/install_generator.rb",
29
+ "lib/generators/remoting/recipe.rb",
29
30
  "lib/remoting.rb",
30
31
  "lib/remoting/commander.rb",
31
32
  "lib/remoting/config.rb",
@@ -37,6 +38,14 @@ Gem::Specification.new do |s|
37
38
  "lib/remoting/shell.rb",
38
39
  "lib/remoting/ssh.rb",
39
40
  "lib/remoting/task.rb",
41
+ "recipes/apache.rake",
42
+ "recipes/bare.rake",
43
+ "recipes/git.rake",
44
+ "recipes/precompile_assets_on_deploy.rake",
45
+ "recipes/rails.rake",
46
+ "recipes/slow_assets_workaround.rake",
47
+ "recipes/utils.rake",
48
+ "recipes/whenever.rake",
40
49
  "remoting.gemspec"
41
50
  ]
42
51
  s.homepage = "http://github.com/mcasimir/remoting"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remoting
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.14
4
+ version: 0.2.16
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-23 00:00:00.000000000 Z
12
+ date: 2012-08-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -78,6 +78,7 @@ files:
78
78
  - examples/remote.rake
79
79
  - examples/remote.yml
80
80
  - lib/generators/remoting/install_generator.rb
81
+ - lib/generators/remoting/recipe.rb
81
82
  - lib/remoting.rb
82
83
  - lib/remoting/commander.rb
83
84
  - lib/remoting/config.rb
@@ -89,6 +90,14 @@ files:
89
90
  - lib/remoting/shell.rb
90
91
  - lib/remoting/ssh.rb
91
92
  - lib/remoting/task.rb
93
+ - recipes/apache.rake
94
+ - recipes/bare.rake
95
+ - recipes/git.rake
96
+ - recipes/precompile_assets_on_deploy.rake
97
+ - recipes/rails.rake
98
+ - recipes/slow_assets_workaround.rake
99
+ - recipes/utils.rake
100
+ - recipes/whenever.rake
92
101
  - remoting.gemspec
93
102
  homepage: http://github.com/mcasimir/remoting
94
103
  licenses:
@@ -105,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
105
114
  version: '0'
106
115
  segments:
107
116
  - 0
108
- hash: 1734298160220380698
117
+ hash: 2814619444637718291
109
118
  required_rubygems_version: !ruby/object:Gem::Requirement
110
119
  none: false
111
120
  requirements: