Skip to content

Commit 97488e2

Browse files
committed
Add monitoring for resilientdb performance from rescanvas operations
1 parent 02d324f commit 97488e2

24 files changed

+3842
-41
lines changed

.gitignore

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2-
# dependencies
31
/node_modules
42
/.pnp
53
.pnp.js
6-
# testing
74
/coverage
8-
# production
95
/build
10-
# misc
116
.DS_Store
127
.env.local
138
.env.development.local
@@ -37,10 +32,11 @@ backend/.coverage
3732
node_modules
3833
backend/qdrant_storage/
3934
frontend/build/
40-
41-
# Exclude all .env files
35+
*.md
36+
*.txt
37+
*clavix*
38+
*build*
39+
*BUILD*
4240
.env
4341
.env.*
44-
45-
# But include .env.example files
4642
!.env.example

backend/app.py

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,10 @@ def handle_all_exceptions(e):
206206

207207
from flask_socketio import SocketIO
208208
import services.socketio_service as socketio_service
209-
socketio = SocketIO(app, cors_allowed_origins=cors_origins, async_mode="threading")
209+
# SocketIO doesn't support regex patterns in cors_allowed_origins, so we use "*" for dev
210+
# or explicit_allowed for production (set via ALLOWED_ORIGINS env var)
211+
socketio_cors_origins = explicit_allowed if explicit_allowed else "*"
212+
socketio = SocketIO(app, cors_allowed_origins=socketio_cors_origins, async_mode="threading")
210213
socketio_service.socketio = socketio
211214
socketio_service.register_socketio_handlers()
212215

@@ -255,24 +258,31 @@ def handle_all_exceptions(e):
255258
atexit.register(stop_retry_worker)
256259

257260
if __name__ == '__main__':
258-
if not redis_client.exists('res-canvas-draw-count'):
259-
init_count = {"id": "res-canvas-draw-count", "value": 0}
260-
logger = __import__('logging').getLogger(__name__)
261-
logger.error("Initialize res-canvas-draw-count if not present in Redis: ", init_count)
262-
init_payload = {
263-
"operation": "CREATE",
264-
"amount": 1,
265-
"signerPublicKey": SIGNER_PUBLIC_KEY,
266-
"signerPrivateKey": SIGNER_PRIVATE_KEY,
267-
"recipientPublicKey": RECIPIENT_PUBLIC_KEY,
268-
"asset": {
269-
"data": {
270-
"id": "res-canvas-draw-count",
271-
"value": 0
261+
logger = __import__('logging').getLogger(__name__)
262+
try:
263+
if not redis_client.exists('res-canvas-draw-count'):
264+
init_count = {"id": "res-canvas-draw-count", "value": 0}
265+
logger.info("Initialize res-canvas-draw-count if not present in Redis: %s", init_count)
266+
init_payload = {
267+
"operation": "CREATE",
268+
"amount": 1,
269+
"signerPublicKey": SIGNER_PUBLIC_KEY,
270+
"signerPrivateKey": SIGNER_PRIVATE_KEY,
271+
"recipientPublicKey": RECIPIENT_PUBLIC_KEY,
272+
"asset": {
273+
"data": {
274+
"id": "res-canvas-draw-count",
275+
"value": 0
276+
}
272277
}
273278
}
274-
}
275279

276-
commit_transaction_via_graphql(init_payload)
277-
redis_client.set('res-canvas-draw-count', 0)
280+
try:
281+
commit_transaction_via_graphql(init_payload)
282+
except Exception as e:
283+
logger.warning("Could not commit init transaction to GraphQL (service may be unavailable): %s", e)
284+
redis_client.set('res-canvas-draw-count', 0)
285+
except Exception as e:
286+
logger.warning("Could not initialize draw count (Redis may be unavailable): %s", e)
287+
278288
socketio.run(app, debug=False, host="0.0.0.0", port=10010, allow_unsafe_werkzeug=True, log_output=True)

0 commit comments

Comments
 (0)