Class: OsCtld::ContainerControl::Commands::StopByHalt::Runner
- Includes:
- Utils::Wall::Runner
- Defined in:
- lib/osctld/container_control/commands/stop_by_halt.rb
Constant Summary
Constants inherited from Runner
Instance Attribute Summary
Attributes inherited from Runner
#ctid, #log_file, #lxc_home, #network_socket, #pool, #stderr, #stdin, #stdout, #user_home
Instance Method Summary collapse
-
#execute(opts) ⇒ Integer
Exit status.
Methods included from Utils::Wall::Runner
Methods inherited from Runner
#error, #exitstatus, #initialize, #lxc_attach_command, #lxc_attach_wait, #lxc_attach_wait_for_exit, #lxc_ct, #ok, #reap_interrupted_lxc_attach, #setup_exec_env, #setup_exec_run_env, #system_path, #wait_for_lxc_attachable, #wait_for_lxc_stopped, #wait_for_path, #wait_for_process, #wait_status_exitstatus
Constructor Details
This class inherits a constructor from OsCtld::ContainerControl::Runner
Instance Method Details
#execute(opts) ⇒ Integer
Returns exit status.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/osctld/container_control/commands/stop_by_halt.rb', line 37 def execute(opts) if opts[:message] begin ct_wall(opts[:message]) rescue LXC::Error # ignore end end exit_status = lxc_attach_wait do setup_exec_env ENV['HOME'] = '/root' ENV['USER'] = 'root' LXC.run_command('halt') end if exit_status == 0 ok else error("halt failed with exit status #{exit_status}") end end |