capistrano-twingly 3.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4cefe904ac4285bcda917e3ca3221abe5ab6454b
4
- data.tar.gz: 5e223b0068c1578c78d4d467cfcbf90783754a70
2
+ SHA256:
3
+ metadata.gz: 9219f0a0906443a3e14e4fdf7b8bc200b50b4ed0948f75abc0586c1a11b7ce28
4
+ data.tar.gz: e2c7d9bcc2f834158d7a1edaea6644e5f1e506f981dfd1f3365167a25cf9ea25
5
5
  SHA512:
6
- metadata.gz: e68ca32fb17cefaafbd5a8daac48425d7a38b85ee61daaea276ab97b09d00e2755cad121c33a7d63ce6c4c5528004f81d8ad0eef38c2d7377bbc075427f3de0d
7
- data.tar.gz: 5b7ccb8c71703d1a9fabbb6dd9e925755afa7b2184c3b3446cedd710af9900013ed8f5456d4fc5171d8794d21df9d746bd10e765283c4591ef363182aa315049
6
+ metadata.gz: eff5f679774a4d2bd67addff46c89fab8df4350e0e3c1c2750735c7181dd3d0ec8e6c4d6deaefffd43b386a51141333943f45477a21392482281ec24d283f39e
7
+ data.tar.gz: dc753f6f3a80d0b6c90e7c99807fe2e22638b7f849ef411051134b515ad8a3c2dfc4af095b5a2576d0d2cca9bd339faf3d64b6f990ab46f5c7badc44d412e12f
data/.travis.yml CHANGED
@@ -1,28 +1,15 @@
1
1
  language: ruby
2
2
  sudo: false
3
-
4
3
  rvm:
5
4
  - 2.4.2
6
5
  - ruby-head
7
-
8
6
  matrix:
9
7
  allow_failures:
10
8
  - rvm: ruby-head
11
9
  fast_finish: true
12
-
13
10
  before_install:
14
- - gem install bundler
15
-
11
+ - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
12
+ - gem install bundler -v '< 2'
16
13
  cache: bundler
17
-
18
14
  notifications:
19
15
  email: false
20
- hipchat:
21
- rooms:
22
- secure: "ILGWgc1QgHVRhwxWgYo+DxLySgOPdwahOV8py1dlRhi4juRUvMcMJSFYvTS47T1Mm8JSJXGaJtEcz24YgWF4XQsL2OawntdxJDNuzmFhF0fC+syN3qHXVzaRIplfcbGOj5rW4Uga8HumvvrQl/g5fscgsGM02BAOKgJhRPM7YLY="
23
- on_success: never
24
- on_failure: change
25
- template:
26
- - '%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}
27
- (<a href="%{build_url}">Details</a>/<a href="%{compare_url}">Change view</a>)'
28
- format: html
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Change Log
2
2
 
3
+ ## [v3.0.0](https://github.com/twingly/capistrano-twingly/tree/v3.0.0) (2018-11-08)
4
+ [Full Changelog](https://github.com/twingly/capistrano-twingly/compare/v2.4.1...v3.0.0)
5
+
6
+ **Merged pull requests:**
7
+
8
+ - Remove LKP traces [\#44](https://github.com/twingly/capistrano-twingly/pull/44) ([walro](https://github.com/walro))
9
+
3
10
  ## [v2.4.1](https://github.com/twingly/capistrano-twingly/tree/v2.4.1) (2018-10-05)
4
11
  [Full Changelog](https://github.com/twingly/capistrano-twingly/compare/v2.4.0...v2.4.1)
5
12
 
data/README.md CHANGED
@@ -56,11 +56,11 @@ namespace :deploy do
56
56
  end
57
57
  ```
58
58
 
59
- ### Upstart
59
+ ### Upstart/Systemd
60
60
 
61
61
  ```Ruby
62
62
  # Capfile
63
- require 'capistrano/twingly/upstart'
63
+ require 'capistrano/twingly/service'
64
64
 
65
65
  # config/deploy.rb
66
66
  set :procfile_contents, -> {
@@ -74,29 +74,6 @@ set :procfile_contents, -> {
74
74
  }
75
75
 
76
76
  namespace :deploy do
77
- desc 'Start application'
78
- task :start do
79
- invoke 'deploy:export_upstart'
80
- on roles(:app) do
81
- sudo :start, fetch(:application)
82
- end
83
- end
84
-
85
- desc 'Restart application'
86
- task :restart do
87
- invoke 'deploy:export_upstart'
88
- on roles(:app) do
89
- execute "sudo restart #{fetch(:application)} || sudo start #{fetch(:application)}"
90
- end
91
- end
92
-
93
- desc 'Stop application'
94
- task :stop do
95
- on roles(:app) do
96
- sudo :stop, fetch(:application)
97
- end
98
- end
99
-
100
77
  after :stop, 'deploy:disable_autostart'
101
78
  after :start, 'deploy:enable_autostart'
102
79
  after :restart, 'deploy:enable_autostart'
@@ -148,13 +125,13 @@ end
148
125
 
149
126
  * Bump the version in `capistrano-twingly.gemspec` in a commit, no need to push (the release task does that).
150
127
 
128
+ * Ensure you are signed in to RubyGems.org as [twingly][twingly-rubygems] with `gem signin`.
129
+
151
130
  * Build and [publish](http://guides.rubygems.org/publishing/) the gem. This will create the proper tag in git, push the commit and tag and upload to RubyGems.
152
131
 
153
132
  bundle exec rake release
154
133
 
155
- * If you are not logged in as [twingly][twingly-rubygems] with ruby gems, the rake task will fail and tell you to set credentials via `gem push`, do that and run the `release` task again. It will be okay.
156
-
157
- * Update the changelog with [GitHub Changelog Generator](https://github.com/skywinder/github-changelog-generator/) (`gem install github_changelog_generator` if you don't have it, set `CHANGELOG_GITHUB_TOKEN` to a personal access token to avoid rate limiting by GitHub). This command will update `CHANGELOG.md`, commit and push manually.
134
+ * Update the changelog with [GitHub Changelog Generator](https://github.com/skywinder/github-changelog-generator/) (`gem install github_changelog_generator` if you don't have it, set `CHANGELOG_GITHUB_TOKEN` to a personal access token to avoid rate limiting by GitHub). This command will update `CHANGELOG.md`. You need to commit and push manually.
158
135
 
159
136
  github_changelog_generator
160
137
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "capistrano-twingly"
7
- spec.version = '3.0.0'
7
+ spec.version = '4.0.0'
8
8
  spec.authors = ["Twingly AB"]
9
9
  spec.email = ["support@twingly.com"]
10
10
  spec.summary = %q{Capistrano 3 tasks used for Twingly's Ruby deployment}
@@ -13,7 +13,7 @@ require "capistrano/bundler"
13
13
 
14
14
  # Twingly tasks
15
15
  require "capistrano/twingly/nginx"
16
- require "capistrano/twingly/upstart"
16
+ require "capistrano/twingly/service"
17
17
  require "capistrano/twingly/tag_deploy_in_git"
18
18
  require "capistrano/twingly/current_git_branch"
19
19
  require "capistrano/twingly/servers_from_srv_record"
@@ -0,0 +1 @@
1
+ load File.expand_path("../tasks/service.rake", __FILE__)
@@ -0,0 +1,123 @@
1
+ namespace :deploy do
2
+ set :bundle_binstubs, -> { shared_path.join('bin') }
3
+
4
+ desc 'Lookup which service manager is used on each server'
5
+ task :lookup_server_service_manager do
6
+ init_system_pid = 1
7
+
8
+ on roles(:app) do |host|
9
+ service_manager_name =
10
+ capture "ps -p#{init_system_pid} co command | grep systemd || echo upstart"
11
+
12
+ server(host).add_role(service_manager_name.to_sym)
13
+ end
14
+ end
15
+
16
+ desc 'Export service script'
17
+ task export_service: %w[lookup_server_service_manager foreman:upload_procfile] do
18
+ on roles(:upstart) do
19
+ within current_path do
20
+ sudo fetch(:chruby_exec), "#{fetch(:chruby_ruby)} -- #{fetch(:bundle_binstubs)}/foreman export upstart /etc/init -a #{fetch(:application)} -u \`whoami\` -l #{shared_path}/log"
21
+ end
22
+ end
23
+
24
+ on roles(:systemd) do
25
+ sudo :systemctl, "stop #{fetch(:application)}.target"
26
+
27
+ within current_path do
28
+ sudo fetch(:chruby_exec), "#{fetch(:chruby_ruby)} -- #{fetch(:bundle_binstubs)}/foreman export systemd /etc/systemd/system -a #{fetch(:application)} -u \`whoami\` -l #{shared_path}/log"
29
+ end
30
+
31
+ sudo :systemctl, "daemon-reload"
32
+ end
33
+ end
34
+
35
+ desc "Start application"
36
+ task start: :lookup_server_service_manager do
37
+ invoke "deploy:export_service"
38
+
39
+ on roles(:upstart) do
40
+ sudo :start, fetch(:application)
41
+ end
42
+
43
+ on roles(:systemd) do
44
+ sudo :systemctl, "start #{fetch(:application)}.target"
45
+ end
46
+ end
47
+
48
+ desc "Restart application"
49
+ task restart: :lookup_server_service_manager do
50
+ invoke "deploy:export_service"
51
+
52
+ on roles(:upstart) do
53
+ execute "sudo restart #{fetch(:application)} || sudo start #{fetch(:application)}"
54
+ end
55
+
56
+ on roles(:systemd) do
57
+ application = fetch(:application)
58
+ execute "sudo systemctl restart #{application}.target || sudo systemctl start #{application}.target"
59
+ end
60
+ end
61
+
62
+ desc "Stop application"
63
+ task stop: :lookup_server_service_manager do
64
+ on roles(:upstart) do
65
+ sudo :stop, fetch(:application)
66
+ end
67
+
68
+ on roles(:systemd) do
69
+ sudo :systemctl, "stop #{fetch(:application)}.target"
70
+ end
71
+ end
72
+
73
+ task disable_autostart: :lookup_server_service_manager do
74
+ on roles(:upstart) do
75
+ execute "/bin/echo manual | sudo /usr/bin/tee /etc/init/#{fetch(:application)}.override"
76
+ end
77
+
78
+ on roles(:systemd) do
79
+ sudo :systemctl, "disable #{fetch(:application)}.target"
80
+ end
81
+ end
82
+
83
+ task enable_autostart: :lookup_server_service_manager do
84
+ on roles(:upstart) do
85
+ execute "/bin/echo | sudo /usr/bin/tee /etc/init/#{fetch(:application)}.override"
86
+ end
87
+
88
+ on roles(:systemd) do
89
+ sudo :systemctl, "enable #{fetch(:application)}.target"
90
+ end
91
+ end
92
+
93
+ namespace :foreman do
94
+ desc 'Upload Procfile to server'
95
+ task upload_procfile: :generate_procfile do
96
+ on roles(:app) do |host|
97
+ upload! "tmp/Procfile_#{host.hostname}", "#{fetch(:deploy_to)}/current/Procfile"
98
+ end
99
+ end
100
+
101
+ desc 'Generate Procfile'
102
+ task :generate_procfile do
103
+ Dir.mkdir('tmp') unless Dir.exist?('tmp')
104
+
105
+ procfile_contents = fetch(:procfile_contents)
106
+
107
+ on roles(:app) do |host|
108
+ procfile_contents_string =
109
+ if procfile_contents.is_a?(Hash)
110
+ procfile_contents.fetch(host.hostname)
111
+ else
112
+ procfile_contents
113
+ end
114
+
115
+ File.open("tmp/Procfile_#{host.hostname}", 'w') do |conf|
116
+ procfile_contents_string.each_line do |line|
117
+ conf.puts "#{line.chomp} 2>&1 | logger -t #{fetch(:app_name)}"
118
+ end
119
+ end
120
+ end
121
+ end
122
+ end
123
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-twingly
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Twingly AB
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-08 00:00:00.000000000 Z
11
+ date: 2019-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -182,13 +182,13 @@ files:
182
182
  - lib/capistrano/twingly/current_git_branch.rb
183
183
  - lib/capistrano/twingly/nginx.rb
184
184
  - lib/capistrano/twingly/servers_from_srv_record.rb
185
+ - lib/capistrano/twingly/service.rb
185
186
  - lib/capistrano/twingly/tag_deploy_in_git.rb
186
187
  - lib/capistrano/twingly/tasks/current_git_branch.rake
187
188
  - lib/capistrano/twingly/tasks/nginx.rake
188
189
  - lib/capistrano/twingly/tasks/servers_from_srv_record.rake
190
+ - lib/capistrano/twingly/tasks/service.rake
189
191
  - lib/capistrano/twingly/tasks/tag_deploy_in_git.rake
190
- - lib/capistrano/twingly/tasks/upstart.rake
191
- - lib/capistrano/twingly/upstart.rb
192
192
  - spec/integration/net_ssh_spec.rb
193
193
  homepage: https://github.com/twingly/capistrano-twingly
194
194
  licenses:
@@ -209,8 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
209
  - !ruby/object:Gem::Version
210
210
  version: '0'
211
211
  requirements: []
212
- rubyforge_project:
213
- rubygems_version: 2.6.14.1
212
+ rubygems_version: 3.0.3
214
213
  signing_key:
215
214
  specification_version: 4
216
215
  summary: Capistrano 3 tasks used for Twingly's Ruby deployment
@@ -1,58 +0,0 @@
1
- namespace :deploy do
2
- set :bundle_binstubs, -> { shared_path.join('bin') }
3
-
4
- desc 'Export upstart script'
5
- task :export_upstart do
6
- on roles(:app) do
7
- within current_path do
8
- sudo fetch(:chruby_exec), "#{fetch(:chruby_ruby)} -- #{fetch(:bundle_binstubs)}/foreman export upstart /etc/init -a #{fetch(:application)} -u \`whoami\` -l #{shared_path}/log"
9
- end
10
- end
11
- end
12
-
13
- task :disable_autostart do
14
- on roles(:app) do
15
- execute "/bin/echo manual | sudo /usr/bin/tee /etc/init/#{fetch(:application)}.override"
16
- end
17
- end
18
-
19
- task :enable_autostart do
20
- on roles(:app) do
21
- execute "/bin/echo | sudo /usr/bin/tee /etc/init/#{fetch(:application)}.override"
22
- end
23
- end
24
-
25
- namespace :foreman do
26
- desc 'Upload Procfile to server'
27
- task :upload_procfile do
28
- on roles(:app) do |host|
29
- upload! "tmp/Procfile_#{host.hostname}", "#{fetch(:deploy_to)}/current/Procfile"
30
- end
31
- end
32
-
33
- desc 'Generate Procfile'
34
- task :generate_procfile do
35
- Dir.mkdir('tmp') unless Dir.exist?('tmp')
36
-
37
- procfile_contents = fetch(:procfile_contents)
38
-
39
- on roles(:app) do |host|
40
- procfile_contents_string =
41
- if procfile_contents.is_a?(Hash)
42
- procfile_contents.fetch(host.hostname)
43
- else
44
- procfile_contents
45
- end
46
-
47
- File.open("tmp/Procfile_#{host.hostname}", 'w') do |conf|
48
- procfile_contents_string.each_line do |line|
49
- conf.puts "#{line.chomp} 2>&1 | logger -t #{fetch(:app_name)}"
50
- end
51
- end
52
- end
53
- end
54
- end
55
-
56
- before 'deploy:export_upstart', 'deploy:foreman:upload_procfile'
57
- before 'deploy:foreman:upload_procfile', 'deploy:foreman:generate_procfile'
58
- end
@@ -1 +0,0 @@
1
- load File.expand_path("../tasks/upstart.rake", __FILE__)