capistrano-running_process_check 0.2.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: f819d42aaa4ac84c3f4306d3212898ed70bc75d2688c5f6a425f16ac2b1dc047
4
+ data.tar.gz: d4121b327dfa023d24162430d21100709e683598e5184f7d436d218b4105c1cf
5
+ SHA512:
6
+ metadata.gz: 99993d093311bbbe0df49f3a7fea3c193df9408845ab626e7c336bface772266fc04d235447897150b475f2c415c5db6a6b7f9ef20a772eaa038f377a8bac184
7
+ data.tar.gz: 9aacf29cce3b94bf9826215f9b475bdc8cd03f17251e68e2bea9f0ceb65123c2f691b0765466a2e9ee8247c7471a020aa5943c89b58d741f55d80f995e282213
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,134 @@
1
+ AllCops:
2
+ Exclude:
3
+ - bin/*
4
+ - node_modules/**/*
5
+ NewCops: enable
6
+ TargetRubyVersion: "2.6"
7
+
8
+ Layout/CaseIndentation:
9
+ EnforcedStyle: end
10
+
11
+ Layout/EndAlignment:
12
+ EnforcedStyleAlignWith: variable
13
+
14
+ Layout/LineLength:
15
+ Enabled: false
16
+
17
+ Layout/EmptyLinesAroundAccessModifier:
18
+ EnforcedStyle: only_before
19
+
20
+ Layout/SpaceInLambdaLiteral:
21
+ EnforcedStyle: require_space
22
+
23
+ Layout/SpaceInsideBlockBraces:
24
+ SpaceBeforeBlockParameters: false
25
+
26
+ Layout/SpaceInsideHashLiteralBraces:
27
+ EnforcedStyle: no_space
28
+
29
+ Metrics/AbcSize:
30
+ Enabled: false
31
+
32
+ Metrics/BlockLength:
33
+ Enabled: false
34
+
35
+ Metrics/ClassLength:
36
+ Enabled: false
37
+
38
+ Metrics/CyclomaticComplexity:
39
+ Enabled: false
40
+
41
+ Metrics/MethodLength:
42
+ Enabled: false
43
+
44
+ Metrics/ModuleLength:
45
+ Enabled: false
46
+
47
+ Metrics/PerceivedComplexity:
48
+ Enabled: false
49
+
50
+ Naming/HeredocDelimiterNaming:
51
+ Enabled: false
52
+
53
+ Naming/MethodParameterName:
54
+ Enabled: false
55
+
56
+ Naming/PredicateName:
57
+ Enabled: false
58
+
59
+ Style/Alias:
60
+ EnforcedStyle: prefer_alias_method
61
+
62
+ Style/AsciiComments:
63
+ Enabled: false
64
+
65
+ Style/BlockDelimiters:
66
+ Enabled: false
67
+
68
+ Style/Documentation:
69
+ Enabled: false
70
+
71
+ Style/EmptyCaseCondition:
72
+ Enabled: false
73
+
74
+ Style/EmptyMethod:
75
+ EnforcedStyle: expanded
76
+
77
+ Style/FrozenStringLiteralComment:
78
+ Enabled: false
79
+
80
+ Style/HashAsLastArrayItem:
81
+ Enabled: false
82
+
83
+ Style/HashSyntax:
84
+ Exclude:
85
+ - Rakefile
86
+ - "**/*.rake"
87
+
88
+ Style/Lambda:
89
+ EnforcedStyle: literal
90
+
91
+ Style/IfUnlessModifier:
92
+ Enabled: false
93
+
94
+ Style/KeywordParametersOrder:
95
+ Enabled: false
96
+
97
+ Style/MultilineBlockChain:
98
+ Enabled: false
99
+
100
+ Style/NumericLiterals:
101
+ Enabled: false
102
+
103
+ Style/NumericPredicate:
104
+ Enabled: false
105
+
106
+ Style/PercentLiteralDelimiters:
107
+ PreferredDelimiters:
108
+ '%i': '()'
109
+ '%w': '()'
110
+ '%r': '()'
111
+
112
+ Style/SpecialGlobalVars:
113
+ Enabled: false
114
+
115
+ Style/StringLiterals:
116
+ EnforcedStyle: double_quotes
117
+
118
+ Style/StringLiteralsInInterpolation:
119
+ EnforcedStyle: double_quotes
120
+
121
+ Style/SymbolArray:
122
+ Enabled: false
123
+
124
+ Style/TrailingCommaInArguments:
125
+ EnforcedStyleForMultiline: consistent_comma
126
+
127
+ Style/TrailingCommaInArrayLiteral:
128
+ EnforcedStyleForMultiline: consistent_comma
129
+
130
+ Style/TrailingCommaInHashLiteral:
131
+ EnforcedStyleForMultiline: consistent_comma
132
+
133
+ Style/ZeroLengthPredicate:
134
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 3.1.0
6
+ before_install: gem install bundler -v 2.1.2
data/CHAGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ # v0.2.0
2
+ * Support regexp.
3
+
4
+ # v0.1.0
5
+
6
+ * Initial release.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in capistrano-running_process_check.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,74 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ capistrano-running_process_check (0.2.0)
5
+ capistrano (>= 3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ airbrussh (1.4.1)
11
+ sshkit (>= 1.6.1, != 1.7.0)
12
+ ast (2.4.2)
13
+ capistrano (3.17.1)
14
+ airbrussh (>= 1.0.0)
15
+ i18n
16
+ rake (>= 10.0.0)
17
+ sshkit (>= 1.9.0)
18
+ concurrent-ruby (1.1.10)
19
+ diff-lcs (1.5.0)
20
+ i18n (1.12.0)
21
+ concurrent-ruby (~> 1.0)
22
+ json (2.6.2)
23
+ net-scp (4.0.0)
24
+ net-ssh (>= 2.6.5, < 8.0.0)
25
+ net-ssh (7.0.1)
26
+ parallel (1.22.1)
27
+ parser (3.1.2.1)
28
+ ast (~> 2.4.1)
29
+ rainbow (3.1.1)
30
+ rake (12.3.3)
31
+ regexp_parser (2.6.0)
32
+ rexml (3.2.5)
33
+ rspec (3.11.0)
34
+ rspec-core (~> 3.11.0)
35
+ rspec-expectations (~> 3.11.0)
36
+ rspec-mocks (~> 3.11.0)
37
+ rspec-core (3.11.0)
38
+ rspec-support (~> 3.11.0)
39
+ rspec-expectations (3.11.1)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.11.0)
42
+ rspec-mocks (3.11.2)
43
+ diff-lcs (>= 1.2.0, < 2.0)
44
+ rspec-support (~> 3.11.0)
45
+ rspec-support (3.11.1)
46
+ rubocop (1.37.1)
47
+ json (~> 2.3)
48
+ parallel (~> 1.10)
49
+ parser (>= 3.1.2.1)
50
+ rainbow (>= 2.2.2, < 4.0)
51
+ regexp_parser (>= 1.8, < 3.0)
52
+ rexml (>= 3.2.5, < 4.0)
53
+ rubocop-ast (>= 1.23.0, < 2.0)
54
+ ruby-progressbar (~> 1.7)
55
+ unicode-display_width (>= 1.4.0, < 3.0)
56
+ rubocop-ast (1.23.0)
57
+ parser (>= 3.1.1.0)
58
+ ruby-progressbar (1.11.0)
59
+ sshkit (1.21.3)
60
+ net-scp (>= 1.1.2)
61
+ net-ssh (>= 2.8.0)
62
+ unicode-display_width (2.3.0)
63
+
64
+ PLATFORMS
65
+ arm64-darwin-21
66
+
67
+ DEPENDENCIES
68
+ capistrano-running_process_check!
69
+ rake (~> 12.0)
70
+ rspec (~> 3.0)
71
+ rubocop (~> 1.37)
72
+
73
+ BUNDLED WITH
74
+ 2.3.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 labocho
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,56 @@
1
+ # Capistrano::RunningProcessCheck
2
+
3
+ This gem checks running process names before all Capistrano tasks, to prevent the process effects deployment.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'capistrano-running_process_check'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install capistrano-running_process_check
20
+
21
+ ## Usage
22
+
23
+
24
+ Add line below to `Capifile`.
25
+
26
+ ```ruby
27
+ require "capistrano/running_process_check"
28
+ ```
29
+
30
+ Please append process names to disallow running while deployment.
31
+
32
+ ```ruby
33
+ append :disallowed_running_processes, /foo/, "bar"
34
+ ```
35
+
36
+ When you run `cap` command (with stage name), checks running process. And if it is running, prints message below and abort deployment.
37
+
38
+ ================================================================================
39
+ !!! Some /foo/ process(es) are running. Please kill them. !!!
40
+ ================================================================================
41
+
42
+
43
+ ## Development
44
+
45
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
46
+
47
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
48
+
49
+ ## Contributing
50
+
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/labocho/capistrano-running_process_check.
52
+
53
+
54
+ ## License
55
+
56
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "capistrano/running_process_check"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/rubocop ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rubocop' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rubocop", "rubocop")
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,34 @@
1
+ require_relative "lib/capistrano/running_process_check/version"
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "capistrano-running_process_check"
5
+ spec.version = Capistrano::RunningProcessCheck::VERSION
6
+ spec.authors = ["labocho"]
7
+ spec.email = ["labocho@penguinlab.jp"]
8
+
9
+ spec.summary = "Add checking runnning process before all Capistrano tasks"
10
+ spec.description = "Add checking runnning process before all Capistrano tasks"
11
+ spec.homepage = "https://github.com/socioart/capistrano-running_process_check"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
14
+
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+ spec.metadata["source_code_uri"] = "https://github.com/socioart/capistrano-running_process_check"
17
+ spec.metadata["changelog_uri"] = "https://github.com/socioart/capistrano-running_process_check/blob/master/CHAGELOG.md"
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
+ `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r(^exe/)) {|f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.add_dependency "capistrano", ">= 3"
29
+
30
+ spec.add_development_dependency "rake", "~> 12.0"
31
+ spec.add_development_dependency "rspec", "~> 3.0"
32
+ spec.add_development_dependency "rubocop", "~> 1.37"
33
+ spec.metadata["rubygems_mfa_required"] = "true"
34
+ end
@@ -0,0 +1 @@
1
+ load File.expand_path("../tasks/running_process_check.rake", __dir__)
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module RunningProcessCheck
3
+ VERSION = "0.2.0".freeze
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "capistrano/running_process_check/version"
2
+ require "capistrano/running_process_check/tasks"
@@ -0,0 +1,27 @@
1
+ Capistrano::DSL.stages.each do |stage|
2
+ after stage, "check:running_process"
3
+ end
4
+
5
+ set :disallowed_running_processes, []
6
+
7
+ namespace :check do
8
+ task :running_process do
9
+ stdout, status = Open3.capture2("ps -o command")
10
+ unless status.success?
11
+ warn "Command failed: ps -o command"
12
+ exit 1
13
+ end
14
+ processes = stdout.strip.each_line.map(&:strip)
15
+
16
+ fetch(:disallowed_running_processes, []).each do |pattern|
17
+ # rubocop:disable Style/CaseEquality
18
+ next unless processes.any? {|process| pattern === process }
19
+ # rubocop:enable Style/CaseEquality
20
+
21
+ warn("=" * 80)
22
+ warn("!!! Some #{pattern.inspect} process(es) are running. Please kill them. !!!")
23
+ warn("=" * 80)
24
+ exit 1
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ # rubocop:disable Naming/FileName
2
+ # If loaded by `Bundler.require`, do nothing.
3
+ # rubocop:enable Naming/FileName
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-running_process_check
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - labocho
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-02-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '12.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '12.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.37'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.37'
69
+ description: Add checking runnning process before all Capistrano tasks
70
+ email:
71
+ - labocho@penguinlab.jp
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".rubocop.yml"
79
+ - ".travis.yml"
80
+ - CHAGELOG.md
81
+ - Gemfile
82
+ - Gemfile.lock
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - bin/console
87
+ - bin/rubocop
88
+ - bin/setup
89
+ - capistrano-running_process_check.gemspec
90
+ - lib/capistrano-running_process_check.rb
91
+ - lib/capistrano/running_process_check.rb
92
+ - lib/capistrano/running_process_check/tasks.rb
93
+ - lib/capistrano/running_process_check/version.rb
94
+ - lib/capistrano/tasks/running_process_check.rake
95
+ homepage: https://github.com/socioart/capistrano-running_process_check
96
+ licenses:
97
+ - MIT
98
+ metadata:
99
+ homepage_uri: https://github.com/socioart/capistrano-running_process_check
100
+ source_code_uri: https://github.com/socioart/capistrano-running_process_check
101
+ changelog_uri: https://github.com/socioart/capistrano-running_process_check/blob/master/CHAGELOG.md
102
+ rubygems_mfa_required: 'true'
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: 2.6.0
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubygems_version: 3.3.3
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: Add checking runnning process before all Capistrano tasks
122
+ test_files: []