Class: OsCtld::Console::Console
- Includes:
- OsCtl::Lib::Utils::Exception
- Defined in:
- lib/osctld/console/console.rb
Overview
Special case for tty0 (/dev/console)
tty0 is opened on container start, at least when it's started by osctld. The tty is accessed using unix server socket created by the osctld container wrapper.
Constant Summary collapse
- CONNECT_RETRY_ERRORS =
[Errno::ENOENT, Errno::ECONNREFUSED].freeze
- CONNECT_RETRY_LIMIT =
100- CONNECT_RETRY_INTERVAL =
0.2
Instance Attribute Summary
Attributes inherited from TTY
#ct, #n, #tty_in_io, #tty_out_io, #tty_pid
Instance Method Summary collapse
- #connect(pid, socket) ⇒ Object
- #expect_run(run_conf) ⇒ Object
- #handles_run?(run_conf) ⇒ Boolean
- #on_close ⇒ Object protected
- #open ⇒ Object
Methods inherited from TTY
#add_client, #client_read, #close, #initialize, #opened?, #remove_client, #start, #sync, #tty_read, #tty_write, #wake, #watch_ios
Methods included from Utils::SwitchUser
Constructor Details
This class inherits a constructor from OsCtld::Console::TTY
Instance Method Details
#connect(pid, socket) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/osctld/console/console.rb', line 31 def connect(pid, socket) expect_run(ct.run_conf) tries = 0 begin c = UNIXSocket.new(socket) rescue *CONNECT_RETRY_ERRORS raise if tries >= CONNECT_RETRY_LIMIT tries += 1 sleep(CONNECT_RETRY_INTERVAL) retry end sync do @opened = true self.tty_pid = pid self.tty_in_io = c self.tty_out_io = c wake end end |
#expect_run(run_conf) ⇒ Object
23 24 25 |
# File 'lib/osctld/console/console.rb', line 23 def expect_run(run_conf) sync { @run_conf = run_conf } end |
#handles_run?(run_conf) ⇒ Boolean
27 28 29 |
# File 'lib/osctld/console/console.rb', line 27 def handles_run?(run_conf) sync { run_conf && @run_conf.equal?(run_conf) } end |
#on_close ⇒ Object (protected)
56 57 58 59 60 |
# File 'lib/osctld/console/console.rb', line 56 def on_close # The current thread is used to handle the console and has to exit. # Manipulation must happen from another thread. Container::StopHandler.schedule(ct, @run_conf) end |
#open ⇒ Object
19 20 21 |
# File 'lib/osctld/console/console.rb', line 19 def open # Does nothing for tty0, it is opened automatically on ct start end |