capelinhos 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +19 -16
- data/CHANGELOG.md +0 -5
- data/LICENSE.txt +0 -21
- data/README.md +0 -36
- data/Rakefile +0 -4
- data/capelinhos.sublime-project +0 -15
- data/exe/capelinhos +0 -52
- data/lib/capelinhos/processor.rb +0 -23
- data/lib/capelinhos/version.rb +0 -5
- data/lib/capelinhos.rb +0 -8
- data/sig/capelinhos.rbs +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7753401a07794ffb5f98ee8d61bb19abc0f9c38b29c3a25f7dfe7eb67ce99867
|
4
|
+
data.tar.gz: d6fea5b09f8433d7ae368def581eee16eba89e5e1436c8783de6721f33963472
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c83bd6ad0b19db0ce7552eab09ede1db1b9b8ebb34ce61d3adefb1a8e403349cbe614a1a5851ba0f8454d776c9908ccadf4bb21af78835a4ad8903b419aeadd
|
7
|
+
data.tar.gz: 5e38b421400e9e4dd07132c46c2546838a15eb7ca6570e481ebd34bef2f5b1ea1e82cf47bc61f2306449a07f934bee7059be7097b9c8cc1c0d64ca9fe0fb8df7
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capelinhos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Hallett
|
@@ -10,20 +10,34 @@ bindir: exe
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2024-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: passenger
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - ">="
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
33
|
+
version: 6.0.12
|
20
34
|
type: :runtime
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
38
|
- - ">="
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
40
|
+
version: 6.0.12
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: byebug
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -41,21 +55,10 @@ dependencies:
|
|
41
55
|
description:
|
42
56
|
email:
|
43
57
|
- adam.t.hallett@gmail.com
|
44
|
-
executables:
|
45
|
-
- capelinhos
|
58
|
+
executables: []
|
46
59
|
extensions: []
|
47
60
|
extra_rdoc_files: []
|
48
|
-
files:
|
49
|
-
- CHANGELOG.md
|
50
|
-
- LICENSE.txt
|
51
|
-
- README.md
|
52
|
-
- Rakefile
|
53
|
-
- capelinhos.sublime-project
|
54
|
-
- exe/capelinhos
|
55
|
-
- lib/capelinhos.rb
|
56
|
-
- lib/capelinhos/processor.rb
|
57
|
-
- lib/capelinhos/version.rb
|
58
|
-
- sig/capelinhos.rbs
|
61
|
+
files: []
|
59
62
|
homepage: https://github.com/atomical/capelinhos
|
60
63
|
licenses:
|
61
64
|
- MIT
|
data/CHANGELOG.md
DELETED
data/LICENSE.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2024 Adam Hallett
|
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
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# Capelinhos
|
2
|
-
|
3
|
-
This gem gracefully stops Passenger Ruby processes that have exceeded a memory threshold. It is meant to be added to cron and run at an interval of your choosing.
|
4
|
-
|
5
|
-
If Phusion Passenger is configured with `PassengerMinInstances` and the number of processes is under that number, then a new process should replace the processes that were shutdown.
|
6
|
-
|
7
|
-
Note: This doesn't skip active long running sessions. This feature be added as a default in the future.
|
8
|
-
|
9
|
-
## Installation
|
10
|
-
|
11
|
-
Install the gem and add to the application's Gemfile by executing:
|
12
|
-
|
13
|
-
$ bundle add capelinhos
|
14
|
-
|
15
|
-
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
|
-
|
17
|
-
$ gem install capelinhos
|
18
|
-
|
19
|
-
## Usage
|
20
|
-
|
21
|
-
# kill up to 3 processes that use more than 400 megabytes
|
22
|
-
$ capelinos --max-memory 400 --max-processes 3
|
23
|
-
|
24
|
-
## Development
|
25
|
-
|
26
|
-
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
27
|
-
|
28
|
-
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
29
|
-
|
30
|
-
## Contributing
|
31
|
-
|
32
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/capelinhos.
|
33
|
-
|
34
|
-
## License
|
35
|
-
|
36
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
DELETED
data/capelinhos.sublime-project
DELETED
data/exe/capelinhos
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'bundler/setup'
|
5
|
-
require 'optparse'
|
6
|
-
require 'capelinhos'
|
7
|
-
|
8
|
-
source_root = File.expand_path("..", File.dirname(__FILE__))
|
9
|
-
$LOAD_PATH.unshift("#{source_root}/src/ruby_supportlib")
|
10
|
-
begin
|
11
|
-
require 'rubygems'
|
12
|
-
rescue LoadError
|
13
|
-
end
|
14
|
-
require 'phusion_passenger'
|
15
|
-
|
16
|
-
PhusionPassenger.locate_directories
|
17
|
-
PhusionPassenger.require_passenger_lib 'platform_info'
|
18
|
-
PhusionPassenger.require_passenger_lib 'platform_info/ruby'
|
19
|
-
PhusionPassenger.require_passenger_lib 'admin_tools/memory_stats'
|
20
|
-
include PhusionPassenger
|
21
|
-
|
22
|
-
options = {}
|
23
|
-
OptionParser.new do |opts|
|
24
|
-
opts.banner = "Usage: capelinhos --max-memory 320 --max-processes 3"
|
25
|
-
|
26
|
-
opts.on("--max-memory", "--max-memory MAX_MEMORY", Numeric, "Maximum memory in megabytes to trigger shutdown.") do |n|
|
27
|
-
options[:max_memory] = n
|
28
|
-
end
|
29
|
-
|
30
|
-
opts.on("--max-processes", "--max-processes=NUMBER", Numeric, "Maximum number of processes to gracefully shutdown.") do |n|
|
31
|
-
options[:max_processes] = n
|
32
|
-
end
|
33
|
-
|
34
|
-
opts.on("-h", "--help", "Prints this help") do
|
35
|
-
puts opts
|
36
|
-
exit
|
37
|
-
end
|
38
|
-
end.parse!
|
39
|
-
|
40
|
-
if !options[:max_memory]
|
41
|
-
puts "--max-memory is required"
|
42
|
-
exit(0)
|
43
|
-
end
|
44
|
-
|
45
|
-
if !options[:max_processes]
|
46
|
-
puts "--max-processes is required"
|
47
|
-
exit(0)
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
|
-
Capelinhos::Processor.kill_memory_hogs!(memory_threshold: options[:max_memory],
|
52
|
-
process_limit: options[:max_processes])
|
data/lib/capelinhos/processor.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module Capelinhos
|
2
|
-
class Processor
|
3
|
-
def self.kill_memory_hogs!(memory_threshold:, process_limit:)
|
4
|
-
processes_killed = 0
|
5
|
-
stats = AdminTools::MemoryStats.new
|
6
|
-
processes = stats.passenger_processes
|
7
|
-
|
8
|
-
processes.each do |process|
|
9
|
-
if process.name.include?('RubyApp')
|
10
|
-
rss_megabytes = process.rss / 1024
|
11
|
-
if rss_megabytes > memory_threshold
|
12
|
-
Process.kill('USR1', process.pid)
|
13
|
-
processes_killed += 1
|
14
|
-
end
|
15
|
-
|
16
|
-
if processes_killed >= process_limit
|
17
|
-
break
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/lib/capelinhos/version.rb
DELETED
data/lib/capelinhos.rb
DELETED
data/sig/capelinhos.rbs
DELETED