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
- #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.
8 9 10 11 12 13 14 15 |
# File 'lib/react_email_rails/render_modes/persistent/server.rb', line 8 def initialize(command) @command = command @mutex = Mutex.new @stderr_buffer = +"" @stderr_mutex = Mutex.new @stdout_buffer = +"" @requests = 0 end |
Instance Method Details
#abandon ⇒ Object
40 41 42 43 44 |
# File 'lib/react_email_rails/render_modes/persistent/server.rb', line 40 def abandon release_io rescue IOError nil end |
#capture(input:, timeout:, max_requests:) ⇒ Object
17 18 19 20 21 |
# File 'lib/react_email_rails/render_modes/persistent/server.rb', line 17 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
23 24 25 |
# File 'lib/react_email_rails/render_modes/persistent/server.rb', line 23 def health_check(timeout:) with_retry_on_broken_pipe { health_check_once(timeout:) } end |
#stop ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/react_email_rails/render_modes/persistent/server.rb', line 27 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 |