Class: Docscribe::Server::Daemon
- Inherits:
-
Object
- Object
- Docscribe::Server::Daemon
- Defined in:
- lib/docscribe/server.rb
Overview
Daemon process that loads the Ruby runtime once and serves requests.
Constant Summary collapse
- ERROR_CODES =
Standardized JSON-RPC error codes.
{ gem_not_found: -32_000, syntax_error: -32_001, config_load_failure: -32_002, timeout: -32_010, internal: -32_099 }.freeze
Instance Method Summary collapse
- #initialize(socket_path: nil, idle_timeout: IDLE_TIMEOUT, config_path: nil) ⇒ void constructor
-
#start ⇒ void
Start the daemon: load dependencies, bind socket, enter listen loop.
Constructor Details
#initialize(socket_path: nil, idle_timeout: IDLE_TIMEOUT, config_path: nil) ⇒ void
364 365 366 367 368 369 370 371 372 373 374 375 |
# File 'lib/docscribe/server.rb', line 364 def initialize(socket_path: nil, idle_timeout: IDLE_TIMEOUT, config_path: nil) @socket_path = socket_path || Server.socket_path(config_path) @idle_timeout = idle_timeout @config_path = config_path @last_request_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) @running = false @server = nil @file_cache = LRUCache.new @started_at = Time.now @cache_mutex = Mutex.new @config_mutex = Mutex.new end |
Instance Method Details
#start ⇒ void
This method returns an undefined value.
Start the daemon: load dependencies, bind socket, enter listen loop.
380 381 382 383 384 385 386 387 |
# File 'lib/docscribe/server.rb', line 380 def start load_dependencies setup_socket @running = true $PROGRAM_NAME = "docscribe server (#{Dir.pwd})" write_pid listen_loop end |