Class: OsCtld::SystemLimits
- Inherits:
-
Object
- Object
- OsCtld::SystemLimits
- Includes:
- OsCtl::Lib::Utils::Log, Lockable, Singleton
- Defined in:
- lib/osctld/system_limits.rb
Overview
Configurator of system-level resource limits
Constant Summary collapse
- FILE_MAX_PATH =
'/proc/sys/fs/file-max'.freeze
- FILE_MAX_DEFAULT =
1024 * 1024
Instance Attribute Summary collapse
-
#values ⇒ Object
readonly
protected
Returns the value of attribute values.
Instance Method Summary collapse
- #ensure_nofile(v) ⇒ Object
-
#initialize ⇒ SystemLimits
constructor
A new instance of SystemLimits.
- #log_type ⇒ Object
Methods included from Lockable
#exclusively, included, #inclusively, #init_lock, #lock, #unlock
Constructor Details
#initialize ⇒ SystemLimits
Returns a new instance of SystemLimits.
23 24 25 26 27 28 |
# File 'lib/osctld/system_limits.rb', line 23 def initialize init_lock @values = {} ensure_nofile(FILE_MAX_DEFAULT) end |
Instance Attribute Details
#values ⇒ Object (readonly, protected)
Returns the value of attribute values.
49 50 51 |
# File 'lib/osctld/system_limits.rb', line 49 def values @values end |
Instance Method Details
#ensure_nofile(v) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/osctld/system_limits.rb', line 31 def ensure_nofile(v) exclusively do values['nofile'] ||= File.read(FILE_MAX_PATH).strip.to_i if values['nofile'] < v log(:info, "Setting #{FILE_MAX_PATH} to #{v}") File.write(FILE_MAX_PATH, v.to_s) values['nofile'] = v end end end |
#log_type ⇒ Object
43 44 45 |
# File 'lib/osctld/system_limits.rb', line 43 def log_type 'system-limits' end |