-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathcallback_server.rb
More file actions
36 lines (33 loc) · 971 Bytes
/
callback_server.rb
File metadata and controls
36 lines (33 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# frozen_string_literal: true
module RubyLLM
module MCP
module Auth
module Browser
# Callback server wrapper for clean shutdown
# Manages server lifecycle and thread coordination
class CallbackServer
def initialize(server, thread, stop_proc, start_proc = nil)
@server = server
@thread = thread
@stop_proc = stop_proc
@start_proc = start_proc || -> {}
end
# Start callback processing loop
def start
@start_proc.call
end
# Shutdown server and cleanup resources
# @return [nil] always returns nil
def shutdown
@stop_proc.call
@server.close unless @server.closed?
@thread.join(5) # Wait max 5 seconds for thread to finish
rescue StandardError
# Ignore shutdown errors
nil
end
end
end
end
end
end