Class: ReactEmailRails::RenderModes::Persistent::Server
- Inherits:
-
Object
- Object
- ReactEmailRails::RenderModes::Persistent::Server
- Defined in:
- lib/react_email_rails/render_modes/persistent/server.rb
Defined Under Namespace
Classes: Status
Constant Summary collapse
- STDERR_LIMIT =
8 * 1024
Instance Method Summary collapse
-
#abandon ⇒ Object
Release this process’s copy of an inherited child’s pipes without signalling the parent-owned process.
- #capture(input:, timeout:, max_requests:) ⇒ Object
- #health_check(timeout:) ⇒ Object
-
#initialize(command) ⇒ Server
constructor
A new instance of Server.
- #stop ⇒ Object
Constructor Details
#initialize(command) ⇒ Server
Returns a new instance of Server.
9 10 11 12 13 14 15 16 |
# File 'lib/react_email_rails/render_modes/persistent/server.rb', line 9 def initialize(command) @command = command @mutex = Mutex.new @stderr_buffer = +"" @stderr_mutex = Mutex.new @stdout_buffer = +"" @requests = 0 end |
Instance Method Details
#abandon ⇒ Object
Release this process’s copy of an inherited child’s pipes without signalling the parent-owned process.
42 43 44 45 46 |
# File 'lib/react_email_rails/render_modes/persistent/server.rb', line 42 def abandon release_io rescue IOError nil end |
#capture(input:, timeout:, max_requests:) ⇒ Object
18 19 20 21 22 |
# File 'lib/react_email_rails/render_modes/persistent/server.rb', line 18 def capture(input:, timeout:, max_requests:) with_retry_on_broken_pipe do capture_once(input:, timeout:).tap { recycle_if_needed(max_requests) } end end |
#health_check(timeout:) ⇒ Object
24 25 26 |
# File 'lib/react_email_rails/render_modes/persistent/server.rb', line 24 def health_check(timeout:) with_retry_on_broken_pipe { health_check_once(timeout:) } end |
#stop ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/react_email_rails/render_modes/persistent/server.rb', line 28 def stop if @wait_thread&.alive? terminate_process("TERM", @wait_thread.pid) @wait_thread.join(1) terminate_process("KILL", @wait_thread.pid) if @wait_thread.alive? end rescue Errno::ESRCH, Errno::EPERM nil ensure @stderr_reader&.kill release_io end |