Module: UCB::UnixEnvironment::ClassMethods
- Defined in:
- lib/ucb_unix_environment.rb
Instance Method Summary collapse
-
#apache_log_dir ⇒ Object
Returns full path of the directory containing the apache logs.
-
#apache_ports ⇒ Object
Returns ports not used by Apache in standard webfarm configurations.
- #domain_name ⇒ Object
-
#gid ⇒ Object
Returns the
gid
. -
#group ⇒ Object
Returns the
group
. -
#http_port ⇒ Object
(also: #non_ssl_port)
Returns the Apache http port.
-
#https_port ⇒ Object
(also: #ssl_port)
Returns the Apache https port.
-
#id_info(symbol) ⇒ Object
:nodoc:.
-
#local_dir ⇒ Object
Returns the local directory of the individual for your account.
-
#machine_name ⇒ Object
Returns the machine name.
-
#mongrel_log_dir ⇒ Object
Returns full path of the directory containing the mongrel logs.
- #mongrel_pid_dir ⇒ Object
-
#mongrel_ports ⇒ Object
Returns ports for mongrel processes.
-
#mongrel_ports=(port_array) ⇒ Object
Setter for mongrel_port_count.
-
#ports ⇒ Object
Returns an
Array
(ofInteger
) of ports. -
#shared_dir ⇒ Object
(also: #home_dir)
Returns the user account home directory.
-
#uid ⇒ Object
Returns the
uid
. - #unix_service ⇒ Object
-
#user ⇒ Object
Returns the
user
. -
#webfarm_id ⇒ Object
Returns the unique identifier of the account instance.
-
#win32? ⇒ Boolean
Returns
true
if on Windows.
Instance Method Details
#apache_log_dir ⇒ Object
Returns full path of the directory containing the apache logs.
86 87 88 |
# File 'lib/ucb_unix_environment.rb', line 86 def apache_log_dir "#{local_dir}/apache2/logs" end |
#apache_ports ⇒ Object
Returns ports not used by Apache in standard webfarm configurations.
150 151 152 |
# File 'lib/ucb_unix_environment.rb', line 150 def apache_ports @apache_ports ||= [http_port, https_port] end |
#domain_name ⇒ Object
59 60 61 62 |
# File 'lib/ucb_unix_environment.rb', line 59 def domain_name return "" if win32? `domainname`.chomp.downcase end |
#gid ⇒ Object
Returns the gid
.
97 98 99 |
# File 'lib/ucb_unix_environment.rb', line 97 def gid id_info(:gid) end |
#group ⇒ Object
Returns the group
.
102 103 104 |
# File 'lib/ucb_unix_environment.rb', line 102 def group id_info(:group) end |
#http_port ⇒ Object Also known as: non_ssl_port
Returns the Apache http port
138 139 140 |
# File 'lib/ucb_unix_environment.rb', line 138 def http_port ports[0] end |
#https_port ⇒ Object Also known as: ssl_port
Returns the Apache https port.
144 145 146 |
# File 'lib/ucb_unix_environment.rb', line 144 def https_port ports[1] end |
#id_info(symbol) ⇒ Object
:nodoc:
116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/ucb_unix_environment.rb', line 116 def id_info(symbol) #:nodoc: unless @id_info @id_info = {} unless win32? login = ENV['LOGNAME'] user = Etc.getpwnam(login) group = Etc.getgrnam(login) @id_info = {:uid => user.uid, :user => user.name, :gid => group.gid, :group => group.name } end end @id_info[symbol] end |
#local_dir ⇒ Object
Returns the local directory of the individual for your account. i.e., not shared across webfarm instances.
72 73 74 |
# File 'lib/ucb_unix_environment.rb', line 72 def local_dir "/users/#{user}/local" end |
#machine_name ⇒ Object
Returns the machine name.
49 50 51 52 |
# File 'lib/ucb_unix_environment.rb', line 49 def machine_name return "" if win32? `uname -n`.chop end |
#mongrel_log_dir ⇒ Object
Returns full path of the directory containing the mongrel logs.
77 78 79 |
# File 'lib/ucb_unix_environment.rb', line 77 def mongrel_log_dir "#{local_dir}/rails/log" end |
#mongrel_pid_dir ⇒ Object
81 82 83 |
# File 'lib/ucb_unix_environment.rb', line 81 def mongrel_pid_dir "#{local_dir}/rails/#{user}/pid" end |
#mongrel_ports ⇒ Object
Returns ports for mongrel processes.
160 161 162 |
# File 'lib/ucb_unix_environment.rb', line 160 def mongrel_ports @mongrel_ports ||= (ports - apache_ports) end |
#mongrel_ports=(port_array) ⇒ Object
Setter for mongrel_port_count.
155 156 157 |
# File 'lib/ucb_unix_environment.rb', line 155 def mongrel_ports=(port_array) @mongrel_ports = port_array end |
#ports ⇒ Object
Returns an Array
(of Integer
) of ports.
133 134 135 |
# File 'lib/ucb_unix_environment.rb', line 133 def ports @ports ||= Array.new(6) { |i| (i*10000) + uid } end |
#shared_dir ⇒ Object Also known as: home_dir
Returns the user account home directory. This is on shared storage across machines.
65 66 67 |
# File 'lib/ucb_unix_environment.rb', line 65 def shared_dir "/users/#{user}" end |
#uid ⇒ Object
Returns the uid
.
107 108 109 |
# File 'lib/ucb_unix_environment.rb', line 107 def uid id_info(:uid) end |
#unix_service ⇒ Object
54 55 56 57 |
# File 'lib/ucb_unix_environment.rb', line 54 def unix_service return "" if win32? machine_name.split('-') end |
#user ⇒ Object
Returns the user
.
112 113 114 |
# File 'lib/ucb_unix_environment.rb', line 112 def user id_info(:user) end |
#webfarm_id ⇒ Object
Returns the unique identifier of the account instance.
91 92 93 |
# File 'lib/ucb_unix_environment.rb', line 91 def webfarm_id uid - 10000 end |
#win32? ⇒ Boolean
Returns true
if on Windows.
44 45 46 |
# File 'lib/ucb_unix_environment.rb', line 44 def win32? RUBY_PLATFORM =~ /win32/ end |