6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/osctld/cli/runner.rb', line 6
def self.run
unless ARGV.empty?
warn "Usage: #{$0}"
exit(false)
end
OsCtl::Lib::Logger.setup(:none)
CGroup.init
cfg = JSON.parse($stdin.readline, symbolize_names: true)
Process.setproctitle(
"osctld: #{cfg[:pool]}:#{cfg[:id]} runner:#{cfg[:name].downcase}"
)
ret = IO.new(cfg[:return])
stdin = cfg[:stdin] && IO.new(cfg[:stdin])
stdout = IO.new(cfg[:stdout])
stderr = IO.new(cfg[:stderr])
[ret, stdin, stdout, stderr].compact.each do |io|
io.close_on_exec = true
end
runner = OsCtld::ContainerControl::Commands.const_get(cfg[:name])::Runner.new(
pool: cfg[:pool],
id: cfg[:id],
lxc_home: cfg[:lxc_home],
user_home: cfg[:user_home],
log_file: cfg[:log_file],
stdin:,
stdout:,
stderr:
)
val = runner.execute(*cfg[:args], **cfg[:kwargs])
ret.puts(val.to_json)
end
|