Class: OsCtld::ContainerControl::Commands::Exec::Runner
- Includes:
- Utils::Runscript::Runner
- Defined in:
- lib/osctld/container_control/commands/exec.rb
Constant Summary
Constants included from Utils::Runscript::Runner
Utils::Runscript::Runner::TRANSIENT_EXIT_TIMEOUT, Utils::Runscript::Runner::TRANSIENT_READY_TIMEOUT
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
- #exec_run(opts) ⇒ Object protected
- #exec_run_network(opts) ⇒ Object protected
- #exec_running(opts) ⇒ Object protected
-
#execute(mode, opts) ⇒ Integer
Exit status.
Methods included from Utils::Runscript::Runner
#osctld_wrapper_callback, #runscript_run, #setup_network, #stop_transient_runner, #wait_transient_ready, #with_configured_network
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
#exec_run(opts) ⇒ Object (protected)
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/osctld/container_control/commands/exec.rb', line 97 def exec_run(opts) pid = Process.fork do $stdin.reopen(stdin) $stdout.reopen(stdout) $stderr.reopen(stderr) setup_exec_run_env osctld_wrapper_callback cmd = [ 'lxc-execute', '-P', lxc_home, '-n', ctid, '-o', log_file, '-s', "lxc.environment=PATH=#{system_path.join(':')}", '-s', 'lxc.environment=HOME=/root', '-s', 'lxc.environment=USER=root', '--', opts[:cmd] ].flatten Process.exec(*cmd) end _, status = Process.wait2(pid) wait_for_lxc_stopped ok(exitstatus(status)) end |
#exec_run_network(opts) ⇒ Object (protected)
127 128 129 130 131 |
# File 'lib/osctld/container_control/commands/exec.rb', line 127 def exec_run_network(opts) with_configured_network( init_script: opts[:init_script] ) { exec_running(opts) } end |
#exec_running(opts) ⇒ Object (protected)
87 88 89 90 91 92 93 94 95 |
# File 'lib/osctld/container_control/commands/exec.rb', line 87 def exec_running(opts) exit_status = lxc_attach_command( opts[:cmd], stdin:, stdout:, stderr: ) ok(exit_status) end |
#execute(mode, opts) ⇒ Integer
Returns exit status.
81 82 83 |
# File 'lib/osctld/container_control/commands/exec.rb', line 81 def execute(mode, opts) send(:"exec_#{mode}", opts) end |