Class: OsCtld::ContainerControl::Commands::Stop::Frontend

Inherits:
Frontend
  • Object
show all
Defined in:
lib/osctld/container_control/commands/stop.rb

Instance Attribute Summary

Attributes inherited from Frontend

#command_class, #ct

Instance Method Summary collapse

Methods inherited from Frontend

#initialize, #pipe_runner

Constructor Details

This class inherits a constructor from OsCtld::ContainerControl::Frontend

Instance Method Details

#execute(mode, opts = {}) ⇒ true

Parameters:

  • mode (:stop, :shutdown, :kill)
  • opts (Hash) (defaults to: {})

    options

Options Hash (opts):

  • :timeout (Integer)

    how log to wait for clean shutdown

Returns:

  • (true)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/osctld/container_control/commands/stop.rb', line 19

def execute(mode, opts = {})
  if !%i(stop shutdown kill).include?(mode)
    raise ArgumentError, "invalid stop mode '#{mode}'"
  end

  CGroup.thaw_tree(ct.cgroup_path) if mode == :kill

  ret = pipe_runner(args: [mode, opts])

  if ret.ok?
    true

  elsif mode == :stop
    CGroup.thaw_tree(ct.cgroup_path)
    ret = pipe_runner(args: [:kill, opts])
    ret.ok? || ret

  else
    ret
  end
end