daytona 0.220.0 → 0.223.0.alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/daytona/common/pty.rb +36 -3
- data/lib/daytona/sdk/version.rb +1 -1
- data/project.json +1 -2
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5c61adcc242e709cff5697fa6001636c5baf5ece820d68bb158c449625f84af4
|
|
4
|
+
data.tar.gz: 652be235803821f815940b2230196ff4f57db02b54061445b58b0c5d920273b9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 89f8d37abacbe2191b5792819fb5895de27ecd81dcc4ded547e1549c893db382231029eb1fa17525b529e00e7328c22d487b0018b2398ce61322100f3fcd50cd
|
|
7
|
+
data.tar.gz: d95e2b4af93d135fd06d4fd3ed3791edb485a5d1720ac9da4891fa929e0481bbb8b4fe49010eff7855bd226bf8d6f2c2a90063099a0b0b21be9521c479da4d22
|
data/lib/daytona/common/pty.rb
CHANGED
|
@@ -65,7 +65,7 @@ module Daytona
|
|
|
65
65
|
# @param session_id [String] Session ID of the PTY session
|
|
66
66
|
# @param handle_resize [Proc, nil] Optional callback for resizing the PTY
|
|
67
67
|
# @param handle_kill [Proc, nil] Optional callback for killing the PTY
|
|
68
|
-
def initialize(websocket, session_id:, handle_resize: nil, handle_kill: nil)
|
|
68
|
+
def initialize(websocket, session_id:, handle_resize: nil, handle_kill: nil) # rubocop:disable Metrics/MethodLength
|
|
69
69
|
@websocket = websocket
|
|
70
70
|
@session_id = session_id
|
|
71
71
|
@handle_resize = handle_resize
|
|
@@ -76,7 +76,9 @@ module Daytona
|
|
|
76
76
|
@logger = Sdk.logger
|
|
77
77
|
|
|
78
78
|
@status = Status::INIT
|
|
79
|
+
@write_mutex = Mutex.new
|
|
79
80
|
subscribe
|
|
81
|
+
start_keepalive
|
|
80
82
|
end
|
|
81
83
|
|
|
82
84
|
# Check if connected to the PTY session
|
|
@@ -108,7 +110,7 @@ module Daytona
|
|
|
108
110
|
def send_input(input)
|
|
109
111
|
raise Sdk::Error, 'PTY session not connected' unless websocket.open?
|
|
110
112
|
|
|
111
|
-
websocket.send(input)
|
|
113
|
+
@write_mutex.synchronize { websocket.send(input) }
|
|
112
114
|
end
|
|
113
115
|
|
|
114
116
|
# Resize the PTY terminal
|
|
@@ -168,10 +170,37 @@ module Daytona
|
|
|
168
170
|
# Disconnect from the PTY session
|
|
169
171
|
#
|
|
170
172
|
# @return [void]
|
|
171
|
-
def disconnect
|
|
173
|
+
def disconnect
|
|
174
|
+
stop_keepalive
|
|
175
|
+
websocket.close
|
|
176
|
+
end
|
|
172
177
|
|
|
173
178
|
private
|
|
174
179
|
|
|
180
|
+
# A PTY can legitimately stay silent for a long time (a build or test run with no
|
|
181
|
+
# output) and intermediate proxies/load balancers drop connections that carry no
|
|
182
|
+
# traffic. Pings keep the connection alive without injecting input into the terminal.
|
|
183
|
+
#
|
|
184
|
+
# @return [void]
|
|
185
|
+
def start_keepalive
|
|
186
|
+
@keepalive_thread = Thread.new do
|
|
187
|
+
loop do
|
|
188
|
+
sleep(KEEPALIVE_INTERVAL)
|
|
189
|
+
break unless websocket.open?
|
|
190
|
+
|
|
191
|
+
@write_mutex.synchronize { websocket.send(nil, type: :ping) }
|
|
192
|
+
end
|
|
193
|
+
rescue StandardError => e
|
|
194
|
+
logger.debug("[Websocket] keepalive stopped: #{e.inspect}")
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# @return [void]
|
|
199
|
+
def stop_keepalive
|
|
200
|
+
@keepalive_thread&.kill
|
|
201
|
+
@keepalive_thread = nil
|
|
202
|
+
end
|
|
203
|
+
|
|
175
204
|
# @return [Symbol]
|
|
176
205
|
attr_reader :status
|
|
177
206
|
|
|
@@ -206,6 +235,7 @@ module Daytona
|
|
|
206
235
|
def on_websocket_close(error)
|
|
207
236
|
logger.debug("[Websocket] close: #{error.inspect}")
|
|
208
237
|
@status = Status::CLOSED
|
|
238
|
+
stop_keepalive
|
|
209
239
|
end
|
|
210
240
|
|
|
211
241
|
# @param error [WebSocket::Frame::Incoming::Client]
|
|
@@ -297,6 +327,9 @@ module Daytona
|
|
|
297
327
|
SLEEP_INTERVAL = 0.1
|
|
298
328
|
private_constant :SLEEP_INTERVAL
|
|
299
329
|
|
|
330
|
+
KEEPALIVE_INTERVAL = 20.0
|
|
331
|
+
private_constant :KEEPALIVE_INTERVAL
|
|
332
|
+
|
|
300
333
|
module Status
|
|
301
334
|
ALL = [
|
|
302
335
|
INIT = 'init',
|
data/lib/daytona/sdk/version.rb
CHANGED
data/project.json
CHANGED
|
@@ -84,8 +84,7 @@
|
|
|
84
84
|
"options": {
|
|
85
85
|
"cwd": "{projectRoot}",
|
|
86
86
|
"commands": [
|
|
87
|
-
"
|
|
88
|
-
"gem push daytona-*.gem --key rubygems --host https://rubygems.org"
|
|
87
|
+
"gem push daytona-*.gem --host https://rubygems.org"
|
|
89
88
|
],
|
|
90
89
|
"parallel": false
|
|
91
90
|
},
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: daytona
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.223.0.alpha.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daytona Platforms Inc.
|
|
@@ -91,42 +91,42 @@ dependencies:
|
|
|
91
91
|
requirements:
|
|
92
92
|
- - '='
|
|
93
93
|
- !ruby/object:Gem::Version
|
|
94
|
-
version: 0.
|
|
94
|
+
version: 0.223.0.alpha.2
|
|
95
95
|
type: :runtime
|
|
96
96
|
prerelease: false
|
|
97
97
|
version_requirements: !ruby/object:Gem::Requirement
|
|
98
98
|
requirements:
|
|
99
99
|
- - '='
|
|
100
100
|
- !ruby/object:Gem::Version
|
|
101
|
-
version: 0.
|
|
101
|
+
version: 0.223.0.alpha.2
|
|
102
102
|
- !ruby/object:Gem::Dependency
|
|
103
103
|
name: daytona_api_client
|
|
104
104
|
requirement: !ruby/object:Gem::Requirement
|
|
105
105
|
requirements:
|
|
106
106
|
- - '='
|
|
107
107
|
- !ruby/object:Gem::Version
|
|
108
|
-
version: 0.
|
|
108
|
+
version: 0.223.0.alpha.2
|
|
109
109
|
type: :runtime
|
|
110
110
|
prerelease: false
|
|
111
111
|
version_requirements: !ruby/object:Gem::Requirement
|
|
112
112
|
requirements:
|
|
113
113
|
- - '='
|
|
114
114
|
- !ruby/object:Gem::Version
|
|
115
|
-
version: 0.
|
|
115
|
+
version: 0.223.0.alpha.2
|
|
116
116
|
- !ruby/object:Gem::Dependency
|
|
117
117
|
name: daytona_toolbox_api_client
|
|
118
118
|
requirement: !ruby/object:Gem::Requirement
|
|
119
119
|
requirements:
|
|
120
120
|
- - '='
|
|
121
121
|
- !ruby/object:Gem::Version
|
|
122
|
-
version: 0.
|
|
122
|
+
version: 0.223.0.alpha.2
|
|
123
123
|
type: :runtime
|
|
124
124
|
prerelease: false
|
|
125
125
|
version_requirements: !ruby/object:Gem::Requirement
|
|
126
126
|
requirements:
|
|
127
127
|
- - '='
|
|
128
128
|
- !ruby/object:Gem::Version
|
|
129
|
-
version: 0.
|
|
129
|
+
version: 0.223.0.alpha.2
|
|
130
130
|
- !ruby/object:Gem::Dependency
|
|
131
131
|
name: dotenv
|
|
132
132
|
requirement: !ruby/object:Gem::Requirement
|