j-cap-recipes 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -4
- data/Gemfile.lock +1 -1
- data/README.md +16 -6
- data/lib/j-cap-recipes/handy.rb +4 -1
- data/lib/j-cap-recipes/rails.rb +1 -42
- data/lib/j-cap-recipes/settings.rb +4 -0
- data/lib/j-cap-recipes/sshkit_runner_patch.rb +42 -0
- data/lib/j-cap-recipes/tasks/database.rake +13 -1
- data/lib/j-cap-recipes/tasks/db.rake +2 -1
- data/lib/j-cap-recipes/tasks/monit.rake +11 -4
- data/lib/j-cap-recipes/tasks/{handy.rake → settings.rake} +7 -0
- data/lib/j-cap-recipes/version.rb +1 -1
- data/lib/sshkit/backends/ssh_command.rb +3 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5196ab571ff7a96196e7a0e7e7a1a740e05e2663
|
4
|
+
data.tar.gz: 51f805237ce8285ebf7f1e4cd3be1d9b6affd735
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8ac7e2590969083d4a2db7712e174f9a155659b25f354a81d814def2e96d78184b35e47b0f4601ba1224bf3477361b2ebae49d80407f5c48c1e180118d860af
|
7
|
+
data.tar.gz: f212f9d82f1006094fc70379a52bbefcbccf521da8224f8a914fa7b2ab339666b4664615638ae4ebd2d7b78deddd3553c9233318e5fe65ca403ec3d7941efba0
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
## Changelog
|
2
2
|
|
3
|
+
## 0.0.16
|
4
|
+
|
5
|
+
* Added handy task to remote edit settings file.
|
6
|
+
* Renamed handy to settings recipes
|
7
|
+
* Updated settings to run default editor instead of only `vi`
|
8
|
+
|
3
9
|
## 0.0.15
|
4
10
|
|
5
11
|
* Added new SSHKit backend called SshCommand. It adds support to run interactive commands, example like `rails console`.
|
6
|
-
* Added rails rake task to create
|
12
|
+
* Added rails rake task to create database backup and restore. You can check `rake -T`
|
7
13
|
* Optimized to run rails console task via SshCommand backend
|
8
14
|
* Added a new task `rails:less_log` to show the current log file via `less`
|
9
15
|
* Update Handy with a new task `config:settings:get` to download remote stage config to local folder.
|
@@ -18,8 +24,8 @@
|
|
18
24
|
|
19
25
|
* Updated recipe git to update remote with new tags.
|
20
26
|
* Remove the old settings before upload a new one.
|
21
|
-
* Added files recipes to
|
22
|
-
* Use capistrano method to get
|
27
|
+
* Added files recipes to download remote files. Use `current` folder to search settings.
|
28
|
+
* Use capistrano method to get revision timestamp for git tagging.
|
23
29
|
|
24
30
|
|
25
31
|
## 0.0.11
|
@@ -39,7 +45,7 @@
|
|
39
45
|
|
40
46
|
## 0.0.6
|
41
47
|
|
42
|
-
* Added deploy
|
48
|
+
* Added deploy notification of the Honeybadger service.
|
43
49
|
|
44
50
|
## 0.0.5
|
45
51
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -45,6 +45,16 @@ Also you need to include rake tasks in your `Rakefile`:
|
|
45
45
|
### Setup
|
46
46
|
### Check
|
47
47
|
### Monit
|
48
|
+
|
49
|
+
### Database recipes
|
50
|
+
|
51
|
+
`cap production db:create`
|
52
|
+
`cap production db:backup`
|
53
|
+
`cap production db:dump_download`
|
54
|
+
`cap production db:dump_upload`
|
55
|
+
`cap production db:restore`
|
56
|
+
|
57
|
+
|
48
58
|
### Rails
|
49
59
|
|
50
60
|
To run remote rails console you should update to the latest gems `capistrano-rbenv` and `capistrano-bundler`
|
@@ -86,16 +96,16 @@ test:
|
|
86
96
|
|
87
97
|
`honeybadger:deploy` - notify the service about deploy and it would be invoked after `deploy:migrate`
|
88
98
|
|
89
|
-
###
|
90
|
-
|
91
|
-
Support to manage https://github.com/bigbinary/handy config files. First should add `require 'j-cap-recipes/handy'` to `Capfile`.
|
92
|
-
There are three tasks available:
|
99
|
+
### Settings
|
93
100
|
|
101
|
+
Support to manage https://github.com/bigbinary/handy config files. First should add `require 'j-cap-recipes/settings'` to `Capfile`.
|
102
|
+
There are tasks available:
|
94
103
|
|
95
104
|
- `cap staging config:settings` Show the current staging config files;
|
96
105
|
- `cap staging config:settings:delete` Remove the custom env settings file;
|
97
106
|
- `cap staging config:settings:upload` Update the remote config file with local one;
|
98
|
-
- `cap staging config:settings:get` Download the
|
107
|
+
- `cap staging config:settings:get` Download the remote config file to local one
|
108
|
+
- `cap staging config:settings:edit` Direct editing of the settings file
|
99
109
|
|
100
110
|
### Git
|
101
111
|
|
@@ -140,7 +150,7 @@ Added utility rake task to create database backup for postgresql and rails.
|
|
140
150
|
|
141
151
|
### SSHKit addon
|
142
152
|
|
143
|
-
`SSHKit::Backend::SshCommand` a new backend to invoke the ssh command using
|
153
|
+
`SSHKit::Backend::SshCommand` a new backend to invoke the ssh command using system command `ssh`.
|
144
154
|
Now you can easy to execute interactive applications with similar changes. Example:
|
145
155
|
|
146
156
|
```ruby
|
data/lib/j-cap-recipes/handy.rb
CHANGED
data/lib/j-cap-recipes/rails.rb
CHANGED
@@ -1,45 +1,4 @@
|
|
1
1
|
require 'sshkit/backends/ssh_command'
|
2
|
-
|
3
|
-
|
4
|
-
#Patch to support backend option
|
5
|
-
# Sent PR https://github.com/capistrano/sshkit/pull/117, except constantinize
|
6
|
-
module SSHKit
|
7
|
-
|
8
|
-
module Runner
|
9
|
-
|
10
|
-
class Abstract
|
11
|
-
|
12
|
-
attr_reader :hosts, :options, :block
|
13
|
-
|
14
|
-
def initialize(hosts, options = nil, &block)
|
15
|
-
@hosts = Array(hosts)
|
16
|
-
@options = options || {}
|
17
|
-
@block = block
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def backend(host, &block)
|
23
|
-
backend_factory.new(host, &block)
|
24
|
-
end
|
25
|
-
|
26
|
-
def backend_factory
|
27
|
-
case @options[:backend]
|
28
|
-
when Symbol
|
29
|
-
SSHKit::Backend.const_get(@options[:backend].to_s.split('_').collect(&:capitalize).join)
|
30
|
-
when String
|
31
|
-
Kernel.const_get(@options[:backend])
|
32
|
-
when nil
|
33
|
-
SSHKit.config.backend
|
34
|
-
else
|
35
|
-
@options[:backend]
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
2
|
+
require_relative 'sshkit_runner_patch'
|
44
3
|
|
45
4
|
load File.expand_path('../tasks/rails.rake', __FILE__)
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'sshkit/runners/abstract'
|
2
|
+
|
3
|
+
#Patch to support backend option
|
4
|
+
# Sent PR https://github.com/capistrano/sshkit/pull/117, except constantinize
|
5
|
+
module SSHKit
|
6
|
+
|
7
|
+
module Runner
|
8
|
+
|
9
|
+
class Abstract
|
10
|
+
|
11
|
+
attr_reader :hosts, :options, :block
|
12
|
+
|
13
|
+
def initialize(hosts, options = nil, &block)
|
14
|
+
@hosts = Array(hosts)
|
15
|
+
@options = options || {}
|
16
|
+
@block = block
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def backend(host, &block)
|
22
|
+
backend_factory.new(host, &block)
|
23
|
+
end
|
24
|
+
|
25
|
+
def backend_factory
|
26
|
+
case @options[:backend]
|
27
|
+
when Symbol
|
28
|
+
SSHKit::Backend.const_get(@options[:backend].to_s.split('_').collect(&:capitalize).join)
|
29
|
+
when String
|
30
|
+
Kernel.const_get(@options[:backend])
|
31
|
+
when nil
|
32
|
+
SSHKit.config.backend
|
33
|
+
else
|
34
|
+
@options[:backend]
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -46,11 +46,23 @@ namespace :db do
|
|
46
46
|
within release_path do
|
47
47
|
FileUtils.mkdir_p 'db/backups'
|
48
48
|
bakup_file = "db/backups/#{fetch(:application)}_#{fetch(:rails_env).to_s}_latest.dump"
|
49
|
-
download! "#{
|
49
|
+
download! "#{release_path}/#{bakup_file}", bakup_file
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
+
desc 'Downlaod to local machine the latest backup'
|
55
|
+
task :dump_upload do
|
56
|
+
on primary fetch(:migration_role) do
|
57
|
+
within release_path do
|
58
|
+
FileUtils.mkdir_p 'db/backups'
|
59
|
+
bakup_file = "db/backups/#{fetch(:application)}_#{fetch(:rails_env).to_s}_latest.dump"
|
60
|
+
upload! bakup_file, "#{release_path}/#{bakup_file}"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
|
54
66
|
end
|
55
67
|
|
56
68
|
remote_file 'config/database.yml' => '/tmp/database.yml', roles: :app
|
@@ -51,7 +51,7 @@ ps xa \
|
|
51
51
|
| grep #{database_name} \
|
52
52
|
| grep -v grep \
|
53
53
|
| awk '{print $1}' \
|
54
|
-
| xargs kill
|
54
|
+
| xargs kill || true
|
55
55
|
EOF
|
56
56
|
sh command
|
57
57
|
end
|
@@ -61,6 +61,7 @@ end
|
|
61
61
|
def postgres_command_options(str, config)
|
62
62
|
str += " -h #{config[:hostname]}" if config[:hostname].present?
|
63
63
|
str += " -U #{config[:username]}" if config[:username].present?
|
64
|
+
str += ' -O -c'
|
64
65
|
str
|
65
66
|
end
|
66
67
|
|
@@ -2,28 +2,35 @@ namespace :monit do
|
|
2
2
|
desc 'Restart monit'
|
3
3
|
task :restart do
|
4
4
|
on roles(:app), in: :sequence, wait: 5 do
|
5
|
-
execute
|
5
|
+
execute :sudo, '/etc/init.d/monit restart'
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
9
|
desc 'Stop monit'
|
10
10
|
task :stop do
|
11
11
|
on roles(:app), in: :sequence, wait: 5 do
|
12
|
-
execute
|
12
|
+
execute :sudo, '/etc/init.d/monit stop'
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
desc 'Start monit'
|
17
17
|
task :start do
|
18
18
|
on roles(:app), in: :sequence, wait: 5 do
|
19
|
-
execute
|
19
|
+
execute :sudo, '/etc/init.d/monit start'
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
desc 'Exec monit command'
|
24
24
|
task :exec, :command do |task, args|
|
25
25
|
on roles(:app), in: :sequence, wait: 5 do
|
26
|
-
execute
|
26
|
+
execute :sudo, :monit, args[:command]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'Reload monit configs'
|
31
|
+
task :reload, :command do |task, args|
|
32
|
+
on roles(:app), in: :sequence, wait: 5 do
|
33
|
+
execute :sudo, :monit, :reload
|
27
34
|
end
|
28
35
|
end
|
29
36
|
end
|
@@ -35,6 +35,13 @@ namespace :config do
|
|
35
35
|
download! current_path.join('config', 'settings', "#{fetch(:stage)}.yml"), local_dir
|
36
36
|
end
|
37
37
|
end
|
38
|
+
|
39
|
+
desc 'Edit remote settings'
|
40
|
+
task :edit do
|
41
|
+
on roles(:app), backend: :ssh_command do |*args|
|
42
|
+
execute('\"\${EDITOR:-vi}\"', current_path.join('config', 'settings', "#{fetch(:stage)}.yml"))
|
43
|
+
end
|
44
|
+
end
|
38
45
|
end
|
39
46
|
|
40
47
|
end
|
@@ -16,7 +16,9 @@ module SSHKit
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def execute(*args, &block)
|
19
|
-
|
19
|
+
host_url = String(host.hostname)
|
20
|
+
host_url = '%s@%s' % [host.username, host_url] if host.username
|
21
|
+
result = 'ssh %s -t "%s"' % [host_url, command(*args).to_command]
|
20
22
|
output << Command.new(result)
|
21
23
|
system(result)
|
22
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: j-cap-recipes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Nikitochkin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -84,7 +84,9 @@ files:
|
|
84
84
|
- lib/j-cap-recipes/rails.rb
|
85
85
|
- lib/j-cap-recipes/railtie.rb
|
86
86
|
- lib/j-cap-recipes/rake.rb
|
87
|
+
- lib/j-cap-recipes/settings.rb
|
87
88
|
- lib/j-cap-recipes/setup.rb
|
89
|
+
- lib/j-cap-recipes/sshkit_runner_patch.rb
|
88
90
|
- lib/j-cap-recipes/tasks/airbrake.rake
|
89
91
|
- lib/j-cap-recipes/tasks/check.rake
|
90
92
|
- lib/j-cap-recipes/tasks/database.rake
|
@@ -93,7 +95,6 @@ files:
|
|
93
95
|
- lib/j-cap-recipes/tasks/deploy.rake
|
94
96
|
- lib/j-cap-recipes/tasks/files.rake
|
95
97
|
- lib/j-cap-recipes/tasks/git.rake
|
96
|
-
- lib/j-cap-recipes/tasks/handy.rake
|
97
98
|
- lib/j-cap-recipes/tasks/honeybadger.rake
|
98
99
|
- lib/j-cap-recipes/tasks/hpusher.rake
|
99
100
|
- lib/j-cap-recipes/tasks/log.rake
|
@@ -101,6 +102,7 @@ files:
|
|
101
102
|
- lib/j-cap-recipes/tasks/nginx.rake
|
102
103
|
- lib/j-cap-recipes/tasks/rails.rake
|
103
104
|
- lib/j-cap-recipes/tasks/rake.rake
|
105
|
+
- lib/j-cap-recipes/tasks/settings.rake
|
104
106
|
- lib/j-cap-recipes/tasks/setup.rake
|
105
107
|
- lib/j-cap-recipes/tasks/templates/database.yml.erb
|
106
108
|
- lib/j-cap-recipes/tasks/unicorn.rake
|