Class: NginxStage::SocketFile
- Inherits:
-
Object
- Object
- NginxStage::SocketFile
- Defined in:
- lib/nginx_stage/socket_file.rb
Overview
A class describing a Unix domain socket
Instance Attribute Summary collapse
-
#socket ⇒ String
readonly
Path to Unix domain socket file.
Instance Method Summary collapse
-
#initialize(socket) ⇒ SocketFile
constructor
A new instance of SocketFile.
-
#sessions ⇒ Integer
The number of active sessions connected to this socket.
-
#to_s ⇒ String
Convert object to string.
Constructor Details
#initialize(socket) ⇒ SocketFile
Returns a new instance of SocketFile.
11 12 13 14 15 16 |
# File 'lib/nginx_stage/socket_file.rb', line 11 def initialize(socket) @socket = socket raise MissingSocketFile, "missing socket file: #{socket}" unless File.exist?(socket) raise InvalidSocketFile, "invalid socket file: #{socket}" unless File.socket?(socket) @processes = get_processes end |
Instance Attribute Details
#socket ⇒ String (readonly)
Path to Unix domain socket file
6 7 8 |
# File 'lib/nginx_stage/socket_file.rb', line 6 def socket @socket end |
Instance Method Details
#sessions ⇒ Integer
The number of active sessions connected to this socket
20 21 22 23 24 25 26 27 |
# File 'lib/nginx_stage/socket_file.rb', line 20 def sessions # generate array of inodes ary_inodes = @processes.map{|h| h[:inode]}.reduce([], :+) # count number of inodes without partner (assuming these are connected to # apache proxy instead of root nginx process) ary_inodes.group_by{|e| e}.select{|k,v| v.size == 1}.map(&:first).count end |
#to_s ⇒ String
Convert object to string
31 32 33 |
# File 'lib/nginx_stage/socket_file.rb', line 31 def to_s socket end |