capistrano3_featureset 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 231ac973fe34af91da551956ba5e43bd31fe2e689814fd40b87ddfdebd101f63
4
+ data.tar.gz: 708e8403c5c5dcf2805a2c9ad4f016df31bc7a38dbe536fb4d418c73b2891a29
5
+ SHA512:
6
+ metadata.gz: 81c2fc24ef4eab4e70d2b67f5b9e1efb45f8909b7be4f4837bffccc682896fffad2a420ea5ae803883afe957c6b41223574aeda2b47e29f234b1e74117c2f5ea
7
+ data.tar.gz: 33f91074feb41afbcec62dadea1f6adaa8e4926f33e30b732d558a8103723959202d0ad748ed71c51f09ced2f92af45d53ac0c0d3f54910b8c8402c3f4ccd1e9
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in m3_capistrano3.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Georg Limbach
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # Capistrano3 - Feature set
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'capistrano3_featureset'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle install
14
+
15
+ Add this to your deployment files:
16
+
17
+ ```ruby
18
+ # Capfile
19
+
20
+ require 'capistrano3_featureset/default'
21
+
22
+ # Load custom tasks from `lib/capistrano/tasks` if you have any defined
23
+ Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
24
+ ```
25
+
26
+ ```ruby
27
+ # config/deploy.rb
28
+
29
+ # config valid for current version and patch releases of Capistrano
30
+ lock '~> 3.11.2'
31
+
32
+ set :application, 'application-name'
33
+ set :repo_url, 'git@github.com:your-repo.git'
34
+ set :deploy_to, '/srv/application-name'
35
+
36
+ set :rvm_ruby_version, '3.1.1'
37
+
38
+ # set :enable_delayed_job, false # default is false
39
+ # set :enable_solid_queue, false # default is false
40
+ # set :enable_whenever, false # default is false
41
+ # set :enable_unicorn, false # default is false
42
+ # set :enable_puma, false # default is false
43
+ # set :systemd_usage, true # default is true
44
+ ```
45
+
46
+ ## License
47
+
48
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
49
+
50
+ ## Integration of Capistrano 3.7.1+ rsync plugin
51
+
52
+ see https://github.com/infovore/capistrano-rsync-plugin
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,24 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = 'capistrano3_featureset'
6
+ spec.version = '1.0.0'
7
+ spec.authors = ['Georg Limbach', 'Tom Armitage', 'Stefan Daschek']
8
+ spec.email = ['georg.limbach@lichtbit.com']
9
+
10
+ spec.summary = 'Capistrano3 feature set'
11
+ spec.description = 'Capistrano3 feature set'
12
+ spec.license = 'MIT'
13
+
14
+ # Specify which files should be added to the gem when it is released.
15
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
16
+ spec.files = Dir.chdir(File.expand_path(__dir__)) { `git ls-files -z`.split("\x0") }
17
+ spec.require_paths = ['lib']
18
+
19
+ spec.add_dependency 'capistrano', '~> 3.0'
20
+ spec.add_dependency 'capistrano-rails'
21
+ spec.add_dependency 'capistrano-rvm'
22
+ spec.add_dependency 'ed25519' # to use modern ssh key ciphers
23
+ spec.add_dependency 'bcrypt_pbkdf' # to use modern ssh key ciphers
24
+ end
@@ -0,0 +1,91 @@
1
+ require 'capistrano/scm/plugin'
2
+
3
+ class Capistrano::SCM
4
+ class Rsync < ::Capistrano::SCM::Plugin
5
+ def set_defaults
6
+ # command-line options for rsync
7
+ set_if_empty :rsync_options, %w[--archive --delete --exclude=.git*]
8
+
9
+ # Local cache (Git checkout will be happen here, resulting files then get rsynced to the remote server)
10
+ set_if_empty :rsync_local_cache, 'tmp/.capistrano-rsync-deploy'
11
+
12
+ # Remote cache on the server. Will be synced with the local cache before each release, and then used as
13
+ # source for the release. Saves needing to transfer all the source files for each release.
14
+ set_if_empty :rsync_remote_cache, 'rsync-deploy'
15
+
16
+ # Git fetch automaticly submodules
17
+ set_if_empty :rsync_git_submodules, true
18
+ end
19
+
20
+ def define_tasks
21
+ namespace :rsync do
22
+ desc <<-DESC
23
+ Copy application source code from (remote) cache to release path.
24
+
25
+ If a :rsync_deploy_build_path is set, only that relative path will \
26
+ be copied to the release path.
27
+ DESC
28
+ task create_release: :update_remote_cache do
29
+ on release_roles :all do
30
+ execute :rsync, '--archive', "#{fetch(:deploy_to)}/#{fetch(:rsync_remote_cache)}/#{fetch(:rsync_deploy_build_path)}", "#{release_path}/"
31
+ end
32
+ end
33
+
34
+ desc <<-DESC
35
+ Update remote cache of application source code.
36
+
37
+ This will be rsynced to :rsync_remote_cache, using rsync options set in \
38
+ :rsync_options
39
+ DESC
40
+ task update_remote_cache: :update_local_cache do
41
+ on release_roles :all do |role|
42
+ host_spec = role.hostname
43
+ host_spec = "#{role.user}@#{host_spec}" if role.user
44
+ run_locally do
45
+ execute :rsync, *fetch(:rsync_options), "#{fetch(:rsync_local_cache)}/", "#{host_spec}:#{fetch(:deploy_to)}/#{fetch(:rsync_remote_cache)}/"
46
+ end
47
+ end
48
+ end
49
+
50
+ desc <<-DESC
51
+ Update local cache of application source code.
52
+
53
+ This will be checked out to :rsync_local_cache.
54
+ DESC
55
+ task :update_local_cache do
56
+ run_locally do
57
+ unless File.exist?("#{fetch(:rsync_local_cache)}/.git")
58
+ FileUtils.mkdir_p(fetch(:rsync_local_cache))
59
+ recursive_submodules = fetch(:rsync_git_submodules) ? '--recurse-submodules' : ''
60
+ execute :git, :clone, recursive_submodules, '--quiet', repo_url, fetch(:rsync_local_cache)
61
+ end
62
+ within fetch(:rsync_local_cache) do
63
+ execute :git, :fetch, '--quiet', '--all', '--prune'
64
+ execute :git, :checkout, fetch(:branch)
65
+ execute :git, :reset, '--quiet', '--hard', "origin/#{fetch(:branch)}"
66
+ execute :git, :submodule, :update, '--recursive', '--init' if fetch(:rsync_git_submodules)
67
+ end
68
+ end
69
+ end
70
+
71
+ desc <<-DESC
72
+ Determine version of code that rsync will deploy.
73
+
74
+ By default, this is the latest version of the code on branch :branch.
75
+ DESC
76
+ task :set_current_revision do
77
+ run_locally do
78
+ within fetch(:rsync_local_cache) do
79
+ set :current_revision, capture(:git, "rev-list --max-count=1 #{fetch(:branch)}")
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
85
+
86
+ def register_hooks
87
+ after 'deploy:new_release_path', 'rsync:create_release'
88
+ before 'deploy:set_current_revision', 'rsync:set_current_revision'
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,19 @@
1
+ # Load DSL and set up stages
2
+ require 'capistrano/setup'
3
+
4
+ # Include default deployment tasks
5
+ require 'capistrano/deploy'
6
+
7
+ # Include rsync with remote cache
8
+ require 'capistrano/rsync'
9
+ install_plugin Capistrano::SCM::Rsync
10
+
11
+ require 'capistrano/rvm'
12
+ require 'capistrano/rails'
13
+ begin
14
+ require 'whenever/capistrano'
15
+ rescue StandardError, LoadError
16
+ nil
17
+ end
18
+
19
+ load File.expand_path('tasks/featureset.rake', __dir__)
@@ -0,0 +1,153 @@
1
+ namespace :featureset do
2
+ desc 'generate static error 500 pages'
3
+ task :generate_static_500_html do
4
+ on roles(:web) do |host|
5
+ next unless host.properties.error_500_url
6
+
7
+ within release_path do
8
+ execute :curl, '-sk', host.properties.error_500_url, '-o', 'public/500.html'
9
+ end
10
+ end
11
+ end
12
+
13
+ desc 'generate static error pages'
14
+ task :generate_static_error_html do
15
+ on roles(:web) do |host|
16
+ next unless host.properties.static_error_urls
17
+ next unless host.properties.static_error_urls.is_a?(Hash)
18
+
19
+ within release_path do
20
+ host.properties.static_error_urls.each do |name, url|
21
+ execute :curl, '-sk', url, '-o', name
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ desc 'load full schema to prevent old migration errors'
28
+ task :db_load_schema do
29
+ on roles(:db) do
30
+ within release_path do
31
+ with(
32
+ rails_env: fetch(:rails_env),
33
+ rails_groups: fetch(:rails_assets_groups),
34
+ disable_database_environment_check: 1,
35
+ ) do
36
+ execute :rake, 'db:environment:set'
37
+ execute :rake, 'db:schema:load'
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ %w[start stop restart upgrade].each do |command|
44
+ desc "#{command} unicorn (init.d)"
45
+ task :"unicorn_#{command}" do
46
+ on roles(:app) do
47
+ unless fetch(:enable_unicorn)
48
+ info 'Unicorn disabled'
49
+ next
50
+ end
51
+
52
+ if fetch(:systemd_usage)
53
+ command = 'reload' if command == 'upgrade'
54
+ execute "sudo", "/usr/sbin/service unicorn_#{fetch(:application)}", command
55
+ else
56
+ execute "/etc/init.d/unicorn_#{fetch(:application)}", command
57
+ end
58
+ end
59
+ end
60
+ end
61
+
62
+ %w[start stop restart reload].each do |command|
63
+ desc "#{command} puma"
64
+ task :"puma_#{command}" do
65
+ on roles(:app) do
66
+ unless fetch(:enable_puma)
67
+ info 'Puma disabled'
68
+ next
69
+ end
70
+
71
+ execute "sudo", "/usr/sbin/service puma_#{fetch(:application)}", command
72
+ end
73
+ end
74
+ end
75
+
76
+ %w[start stop restart].each do |command|
77
+ desc "#{command} delayed_job process"
78
+ task :"delayed_job_#{command}" do
79
+ on roles(:app) do
80
+ unless fetch(:enable_delayed_job)
81
+ info 'Delayed job disabled'
82
+ next
83
+ end
84
+
85
+ if fetch(:systemd_usage)
86
+ execute "sudo", "/usr/sbin/service delayed_job_#{fetch(:application)}", command
87
+ else
88
+ execute "/usr/local/bin/#{fetch(:application)}.delayed_job", command
89
+ end
90
+ end
91
+ end
92
+ end
93
+
94
+ %w[start stop restart].each do |command|
95
+ desc "#{command} solid_queue process"
96
+ task :"solid_queue_#{command}" do
97
+ on roles(:app) do
98
+ unless fetch(:enable_solid_queue)
99
+ info 'Solid queue disabled'
100
+ next
101
+ end
102
+
103
+ execute "sudo", "/usr/sbin/service solid_queue_#{fetch(:application)}", command
104
+ end
105
+ end
106
+ end
107
+
108
+ desc 'Symlink linked directories'
109
+ task :linked_dirs do
110
+ on release_roles :all do
111
+ fetch(:more_linked_dirs).each do |target, source|
112
+ target_path = release_path.join(target)
113
+ source_path = shared_path.join(source)
114
+ execute :mkdir, '-p', target_path.dirname
115
+ next if test "[ -L #{target_path} ]"
116
+
117
+ execute :rm, '-rf', target_path if test "[ -d #{target_path} ]"
118
+ execute :ln, '-s', source_path, target_path
119
+ end
120
+ end
121
+ end
122
+ end
123
+
124
+ namespace :load do
125
+ task :defaults do
126
+ rsync_excludes = %w[.git* spec rspec test Capfile config/deploy config/deploy.rb]
127
+ set :rsync_options, "-azc --delete --delete-excluded --exclude #{rsync_excludes.join(' --exclude ')}"
128
+
129
+ set :rvm_type, :user
130
+
131
+ set :enable_delayed_job, false
132
+ set :enable_solid_queue, false
133
+ set :enable_whenever, false
134
+ set :enable_unicorn, false
135
+ set :enable_puma, false
136
+
137
+ set :systemd_usage, true
138
+
139
+ append :linked_dirs, 'public/uploads'
140
+ append :linked_dirs, 'private'
141
+ append :linked_dirs, 'log'
142
+ set :more_linked_dirs, 'tmp/pids' => 'pids'
143
+ end
144
+ end
145
+
146
+ before 'deploy:migrate', 'featureset:db_load_schema' unless ENV['FIRST_DEPLOYMENT'].nil?
147
+ after 'deploy:publishing', 'featureset:puma_reload'
148
+ after 'deploy:publishing', 'featureset:unicorn_upgrade'
149
+ after 'featureset:unicorn_upgrade', 'featureset:generate_static_500_html'
150
+ after 'featureset:unicorn_upgrade', 'featureset:generate_static_error_html'
151
+ after 'deploy:publishing', 'featureset:delayed_job_restart'
152
+ after 'deploy:publishing', 'featureset:solid_queue_restart'
153
+ after 'deploy:symlink:linked_dirs', 'featureset:linked_dirs'
File without changes
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano3_featureset
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Georg Limbach
8
+ - Tom Armitage
9
+ - Stefan Daschek
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2026-04-28 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: capistrano
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '3.0'
29
+ - !ruby/object:Gem::Dependency
30
+ name: capistrano-rails
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: capistrano-rvm
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ - !ruby/object:Gem::Dependency
58
+ name: ed25519
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ type: :runtime
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ - !ruby/object:Gem::Dependency
72
+ name: bcrypt_pbkdf
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ type: :runtime
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ description: Capistrano3 feature set
86
+ email:
87
+ - georg.limbach@lichtbit.com
88
+ executables: []
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - capistrano3_featureset.gemspec
98
+ - lib/capistrano/rsync.rb
99
+ - lib/capistrano3_featureset.rb
100
+ - lib/capistrano3_featureset/default.rb
101
+ - lib/capistrano3_featureset/tasks/featureset.rake
102
+ homepage:
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubygems_version: 3.3.26
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: Capistrano3 feature set
125
+ test_files: []