Class: OsCtld::UserControl::Supervisor
- Inherits:
-
Object
- Object
- OsCtld::UserControl::Supervisor
show all
- Defined in:
- lib/osctld/user_control/supervisor.rb
Defined Under Namespace
Classes: ClientHandler, NamespacedClientHandler
Constant Summary
collapse
- @@instance =
nil
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.instance ⇒ Object
83
84
85
86
|
# File 'lib/osctld/user_control/supervisor.rb', line 83
def self.instance
@@instance ||= new
@@instance
end
|
Instance Method Details
#start_namespaced ⇒ Object
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
# File 'lib/osctld/user_control/supervisor.rb', line 133
def start_namespaced
sync do
path = File.join(RunState::USER_CONTROL_DIR, 'namespaced.sock')
socket = UNIXServer.new(path)
File.chown(0, 0, path)
File.chmod(0o666, path)
s = Generic::Server.new(socket, NamespacedClientHandler)
t = Thread.new { s.start }
@servers[:namespaced] = [s, t]
end
end
|
#start_server(user) ⇒ Object
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/osctld/user_control/supervisor.rb', line 107
def start_server(user)
sync do
path = socket_path(user)
socket = UNIXServer.new(path)
File.chown(0, user.ugid, path)
File.chmod(0o660, path)
s = Generic::Server.new(socket, ClientHandler, opts: {
user:
})
t = Thread.new { s.start }
@servers[user.name] = [s, t]
end
end
|
#stop_all ⇒ Object
148
149
150
151
152
153
154
155
156
157
|
# File 'lib/osctld/user_control/supervisor.rb', line 148
def stop_all
sync do
@servers.each_value { |st| st[0].stop }
@servers.each_value { |st| st[1].join }
end
s, t = @servers[:namespaced]
s.stop
t.join
end
|
#stop_server(user) ⇒ Object
124
125
126
127
128
129
130
131
|
# File 'lib/osctld/user_control/supervisor.rb', line 124
def stop_server(user)
sync do
s, t = @servers[user.name]
s.stop
t.join
File.unlink(socket_path(user))
end
end
|