j-cap-recipes 0.0.5 → 0.0.7
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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/README.md +5 -0
- data/lib/j-cap-recipes/honeybadger.rb +1 -0
- data/lib/j-cap-recipes/rails.rb +65 -0
- data/lib/j-cap-recipes/tasks/honeybadger.rake +38 -0
- data/lib/j-cap-recipes/tasks/rails.rake +12 -71
- data/lib/j-cap-recipes/version.rb +1 -1
- metadata +15 -28
- data/lib/j-cap-recipes/tasks/templates/nginx/site.conf.erb +0 -28
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b82b43c06483b389c1bf2dcde05f074ce223283d
|
4
|
+
data.tar.gz: d1b2ed07ce382788f30576da2a7ff9ab82490018
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 46891dd595e3a9e03345051290a2d3d951f16ef729e20715b06646349b5e97df1c124962f8628b4001cec8bcb81ecceca5ca73b1b085a6f087ee679cbe45da29
|
7
|
+
data.tar.gz: 8b8c43da7b32fe0ad16f2f9373a9363067c891029f6ca5a6b70e70d82d7d0d7e790674811cccae3339164213b449d79249e2bad8790227efdaa5f73c7bc96267
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,14 @@
|
|
3
3
|
This file is written in reverse chronological order, newer releases will
|
4
4
|
appear at the top.
|
5
5
|
|
6
|
+
## 0.0.7
|
7
|
+
|
8
|
+
* monkey patch SSHKit because capistrano wont to use blocks for execute.
|
9
|
+
|
10
|
+
## 0.0.6
|
11
|
+
|
12
|
+
* Added deploy notifiction of the Honeybadger service.
|
13
|
+
|
6
14
|
## 0.0.5
|
7
15
|
|
8
16
|
* fixed bug: Removed the custom command bin mapping for rails. Updated the rails console behavior.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -34,6 +34,7 @@ If you want to load only specified recipe:
|
|
34
34
|
require 'j-cap-recipes/log'
|
35
35
|
require 'j-cap-recipes/rails'
|
36
36
|
require 'j-cap-recipes/unicorn'
|
37
|
+
require 'j-cap-recipes/honeybadger'
|
37
38
|
|
38
39
|
### Nginx
|
39
40
|
### Setup
|
@@ -44,6 +45,10 @@ If you want to load only specified recipe:
|
|
44
45
|
To run remote rails console you should update to the latest gems `capistrano-rbenv` and `capistrano-bundler`
|
45
46
|
and run command `cap production rails:console`.
|
46
47
|
|
48
|
+
### Honeybadger
|
49
|
+
|
50
|
+
`honeybadger:deploy` - notify the service about deploy and it would be invoked after `deploy:migrate`
|
51
|
+
|
47
52
|
## Contributing
|
48
53
|
|
49
54
|
1. Fork it
|
@@ -0,0 +1 @@
|
|
1
|
+
load File.expand_path('../tasks/honeybadger.rake', __FILE__)
|
data/lib/j-cap-recipes/rails.rb
CHANGED
@@ -1 +1,66 @@
|
|
1
|
+
module SSHKit
|
2
|
+
module Backend
|
3
|
+
class Netssh
|
4
|
+
def execute(*args, &block)
|
5
|
+
_execute(*args, &block).success?
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
def _execute(*args, &block)
|
10
|
+
command(*args).tap do |cmd|
|
11
|
+
output << cmd
|
12
|
+
cmd.started = true
|
13
|
+
ssh.open_channel do |chan|
|
14
|
+
chan.request_pty if Netssh.config.pty
|
15
|
+
chan.exec cmd.to_command do |ch, success|
|
16
|
+
chan.on_data do |ch, data|
|
17
|
+
if block_given?
|
18
|
+
block.call(ch, data)
|
19
|
+
else
|
20
|
+
cmd.stdout = data
|
21
|
+
cmd.full_stdout += data
|
22
|
+
output << cmd
|
23
|
+
end
|
24
|
+
end
|
25
|
+
chan.on_extended_data do |ch, type, data|
|
26
|
+
cmd.stderr = data
|
27
|
+
cmd.full_stderr += data
|
28
|
+
output << cmd
|
29
|
+
end
|
30
|
+
chan.on_request("exit-status") do |ch, data|
|
31
|
+
cmd.stdout = ''
|
32
|
+
cmd.stderr = ''
|
33
|
+
cmd.exit_status = data.read_long
|
34
|
+
output << cmd
|
35
|
+
end
|
36
|
+
#chan.on_request("exit-signal") do |ch, data|
|
37
|
+
# # TODO: This gets called if the program is killed by a signal
|
38
|
+
# # might also be a worthwhile thing to report
|
39
|
+
# exit_signal = data.read_string.to_i
|
40
|
+
# warn ">>> " + exit_signal.inspect
|
41
|
+
# output << cmd
|
42
|
+
#end
|
43
|
+
chan.on_open_failed do |ch|
|
44
|
+
# TODO: What do do here?
|
45
|
+
# I think we should raise something
|
46
|
+
end
|
47
|
+
chan.on_process do |ch|
|
48
|
+
# TODO: I don't know if this is useful
|
49
|
+
end
|
50
|
+
chan.on_eof do |ch|
|
51
|
+
# TODO: chan sends EOF before the exit status has been
|
52
|
+
# writtend
|
53
|
+
end
|
54
|
+
end
|
55
|
+
chan.wait
|
56
|
+
end
|
57
|
+
ssh.loop
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
|
1
66
|
load File.expand_path("../tasks/rails.rake", __FILE__)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
after 'deploy', 'honeybadger:deploy'
|
2
|
+
after 'deploy:migrate', 'honeybadger:deploy'
|
3
|
+
|
4
|
+
namespace :honeybadger do
|
5
|
+
desc <<-DESC
|
6
|
+
Notify Honeybadger of the deployment by running the notification on the REMOTE machine.
|
7
|
+
- Run remotely so we use remote API keys, environment, etc.
|
8
|
+
DESC
|
9
|
+
task :deploy do
|
10
|
+
on roles(:app), reject: lambda { |h| h.properties.no_release } do
|
11
|
+
dry_run = fetch(:dry_run)
|
12
|
+
honeybadger_env = fetch(:honeybadger_env, fetch(:rails_env, 'production'))
|
13
|
+
user = local_user || ENV['USER'] || ENV['USERNAME']
|
14
|
+
async_notify = fetch(:honeybadger_async_notify, false)
|
15
|
+
|
16
|
+
rake_task_args = "TO=#{honeybadger_env} REPO=#{repo_url} USER=#{user}"
|
17
|
+
rake_task_args << " #{ENV['API_KEY']}" if ENV['API_KEY']
|
18
|
+
rake_task_args << ' DRY_RUN=true' if dry_run
|
19
|
+
|
20
|
+
if async_notify
|
21
|
+
rake_task_args << ' nohup'
|
22
|
+
rake_task_args << ' >> /dev/null 2>&1 &'
|
23
|
+
end
|
24
|
+
|
25
|
+
if dry_run
|
26
|
+
info 'DRY RUN: Notification not actually run.'
|
27
|
+
else
|
28
|
+
within fetch(:release_path) do
|
29
|
+
with(rails_env: fetch(:rails_env)) do
|
30
|
+
execute :rake, fetch(:honeybadger_deploy_task, 'honeybadger:deploy'), rake_task_args
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
info 'Honeybadger Notification Complete.'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -4,79 +4,20 @@ namespace :rails do
|
|
4
4
|
on roles(:app) do
|
5
5
|
within release_path do
|
6
6
|
with rails_env: fetch(:rails_env) do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
command(*args).tap do |cmd|
|
20
|
-
output << cmd
|
21
|
-
cmd.started = true
|
22
|
-
ssh.open_channel do |chan|
|
23
|
-
chan.request_pty if Netssh.config.pty
|
24
|
-
chan.exec cmd.to_command do |ch, success|
|
25
|
-
|
26
|
-
chan.on_data do |ch, data|
|
27
|
-
#Rails specific console handler
|
28
|
-
@row ||= ''
|
29
|
-
@row += data
|
30
|
-
if data.include?("\n")
|
31
|
-
cmd.stdout = @row
|
32
|
-
cmd.full_stdout += @row
|
33
|
-
output << cmd
|
34
|
-
@row = ''
|
35
|
-
else
|
36
|
-
if data.include?('irb(main):')
|
37
|
-
print data
|
38
|
-
@row = ''
|
39
|
-
command = $stdin.gets
|
40
|
-
command = "exit\n" if command == nil
|
41
|
-
ch.send_data command
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
chan.on_extended_data do |ch, type, data|
|
47
|
-
cmd.stderr = data
|
48
|
-
cmd.full_stderr += data
|
49
|
-
output << cmd
|
50
|
-
end
|
51
|
-
|
52
|
-
chan.on_request("exit-status") do |ch, data|
|
53
|
-
cmd.stdout = ''
|
54
|
-
cmd.stderr = ''
|
55
|
-
cmd.exit_status = data.read_long
|
56
|
-
output << cmd
|
57
|
-
end
|
58
|
-
#chan.on_request("exit-signal") do |ch, data|
|
59
|
-
# # TODO: This gets called if the program is killed by a signal
|
60
|
-
# # might also be a worthwhile thing to report
|
61
|
-
# exit_signal = data.read_string.to_i
|
62
|
-
# warn ">>> " + exit_signal.inspect
|
63
|
-
# output << cmd
|
64
|
-
#end
|
65
|
-
chan.on_open_failed do |ch|
|
66
|
-
# TODO: What do do here?
|
67
|
-
# I think we should raise something
|
68
|
-
end
|
69
|
-
chan.on_process do |ch|
|
70
|
-
# TODO: I don't know if this is useful
|
71
|
-
end
|
72
|
-
chan.on_eof do |ch|
|
73
|
-
# TODO: chan sends EOF before the exit status has been
|
74
|
-
# writtend
|
75
|
-
end
|
7
|
+
row , command = '', ''
|
8
|
+
execute(:rails, :console) do |ch, data|
|
9
|
+
row += data
|
10
|
+
if data.include?("\n")
|
11
|
+
print row if command.chomp != row.chomp
|
12
|
+
row = ''
|
13
|
+
elsif data.include?('irb(main):')
|
14
|
+
print row
|
15
|
+
row = ''
|
16
|
+
command = $stdin.gets
|
17
|
+
command = "exit\n" if command == nil
|
18
|
+
ch.send_data command
|
76
19
|
end
|
77
|
-
chan.wait
|
78
20
|
end
|
79
|
-
ssh.loop
|
80
21
|
end
|
81
22
|
end
|
82
23
|
end
|
metadata
CHANGED
@@ -1,62 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: j-cap-recipes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.7
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Michael Nikitochkin
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-12-03 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '1.3'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '1.3'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: capistrano
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: 3.0.0
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: 3.0.0
|
62
55
|
description: A litle knife to deploy Rails application
|
@@ -77,6 +70,7 @@ files:
|
|
77
70
|
- lib/j-cap-recipes/check.rb
|
78
71
|
- lib/j-cap-recipes/database.rb
|
79
72
|
- lib/j-cap-recipes/delayed_job.rb
|
73
|
+
- lib/j-cap-recipes/honeybadger.rb
|
80
74
|
- lib/j-cap-recipes/hpusher.rb
|
81
75
|
- lib/j-cap-recipes/log.rb
|
82
76
|
- lib/j-cap-recipes/monit.rb
|
@@ -87,6 +81,7 @@ files:
|
|
87
81
|
- lib/j-cap-recipes/tasks/check.rake
|
88
82
|
- lib/j-cap-recipes/tasks/database.rake
|
89
83
|
- lib/j-cap-recipes/tasks/delayed_job.rake
|
84
|
+
- lib/j-cap-recipes/tasks/honeybadger.rake
|
90
85
|
- lib/j-cap-recipes/tasks/hpusher.rake
|
91
86
|
- lib/j-cap-recipes/tasks/log.rake
|
92
87
|
- lib/j-cap-recipes/tasks/monit.rake
|
@@ -95,39 +90,31 @@ files:
|
|
95
90
|
- lib/j-cap-recipes/tasks/rake.rake
|
96
91
|
- lib/j-cap-recipes/tasks/setup.rake
|
97
92
|
- lib/j-cap-recipes/tasks/templates/database.yml.erb
|
98
|
-
- lib/j-cap-recipes/tasks/templates/nginx/site.conf.erb
|
99
93
|
- lib/j-cap-recipes/tasks/unicorn.rake
|
100
94
|
- lib/j-cap-recipes/unicorn.rb
|
101
95
|
- lib/j-cap-recipes/version.rb
|
102
96
|
homepage: https://github.com/jetthoughts/j-cap-recipes
|
103
97
|
licenses:
|
104
98
|
- MIT
|
99
|
+
metadata: {}
|
105
100
|
post_install_message:
|
106
101
|
rdoc_options: []
|
107
102
|
require_paths:
|
108
103
|
- lib
|
109
104
|
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
-
none: false
|
111
105
|
requirements:
|
112
|
-
- -
|
106
|
+
- - ">="
|
113
107
|
- !ruby/object:Gem::Version
|
114
108
|
version: '0'
|
115
|
-
segments:
|
116
|
-
- 0
|
117
|
-
hash: -3379381580228172657
|
118
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
-
none: false
|
120
110
|
requirements:
|
121
|
-
- -
|
111
|
+
- - ">="
|
122
112
|
- !ruby/object:Gem::Version
|
123
113
|
version: '0'
|
124
|
-
segments:
|
125
|
-
- 0
|
126
|
-
hash: -3379381580228172657
|
127
114
|
requirements: []
|
128
115
|
rubyforge_project:
|
129
|
-
rubygems_version: 1.
|
116
|
+
rubygems_version: 2.1.11
|
130
117
|
signing_key:
|
131
|
-
specification_version:
|
118
|
+
specification_version: 4
|
132
119
|
summary: Capistrano 3 recipes for nginx, monit, rails log, setup, unicorn
|
133
120
|
test_files: []
|
@@ -1,28 +0,0 @@
|
|
1
|
-
upstream <%= fetch(:application) %>_upstream {
|
2
|
-
server unix:<%= shared_path.join('tmp/sockets/unicorn.sock') %> fail_timeout=0;
|
3
|
-
}
|
4
|
-
|
5
|
-
server {
|
6
|
-
listen 80;
|
7
|
-
server_name <%= fetch(:application) %>;
|
8
|
-
|
9
|
-
error_log <%= shared_path.join('log/nginx-error.log') %>;
|
10
|
-
access_log <%= shared_path.join('log/nginx-access.log') %>;
|
11
|
-
|
12
|
-
root <%= current_path.join('public') %>;
|
13
|
-
|
14
|
-
try_files $uri/index.html $uri.html $uri @app;
|
15
|
-
|
16
|
-
location @app {
|
17
|
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
18
|
-
proxy_set_header Host $http_host;
|
19
|
-
proxy_redirect off;
|
20
|
-
|
21
|
-
proxy_pass http://<%= fetch(:application) %>_upstream;
|
22
|
-
}
|
23
|
-
|
24
|
-
error_page 500 502 503 504 /500.html;
|
25
|
-
location = /500.html {
|
26
|
-
root <%= current_path.join('public') %>;
|
27
|
-
}
|
28
|
-
}
|