Skip to content

Commit

Permalink
feat: socketio health check
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush committed Apr 22, 2024
1 parent d7a0ed8 commit 023297b
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 8 deletions.
18 changes: 13 additions & 5 deletions frappe/desk/doctype/system_health_report/system_health_report.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
// Copyright (c) 2024, Frappe Technologies and contributors
// For license information, please see license.txt

// frappe.ui.form.on("System Health Report", {
// refresh(frm) {

// },
// });
frappe.ui.form.on("System Health Report", {
refresh(frm) {
frm.set_value("socketio_ping_check", "Fail");
frappe.realtime.on("pong", () => {
frm.set_value("socketio_ping_check", "Pass");
frm.set_value(
"socketio_transport_mode",
frappe.realtime.socket.io?.engine?.transport?.name
);
});
frappe.realtime.emit("ping");
},
});
36 changes: 34 additions & 2 deletions frappe/desk/doctype/system_health_report/system_health_report.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"background_jobs_tab",
"background_jobs_section",
"scheduler_status",
"column_break_klex",
"total_background_workers",
"section_break_djoz",
"queue_status",
"column_break_wjoz",
"background_workers"
"background_workers",
"realtime_tab",
"socketio_ping_check",
"column_break_hgay",
"socketio_transport_mode"
],
"fields": [
{
Expand Down Expand Up @@ -52,14 +57,41 @@
{
"fieldname": "column_break_wjoz",
"fieldtype": "Column Break"
},
{
"fieldname": "background_jobs_tab",
"fieldtype": "Tab Break",
"label": "Background Jobs"
},
{
"fieldname": "realtime_tab",
"fieldtype": "Tab Break",
"label": "Realtime"
},
{
"default": "Fail",
"fieldname": "socketio_ping_check",
"fieldtype": "Select",
"label": "SocketIO Ping Check",
"options": "Fail\nPass"
},
{
"fieldname": "column_break_hgay",
"fieldtype": "Column Break"
},
{
"fieldname": "socketio_transport_mode",
"fieldtype": "Select",
"label": "SocketIO Transport Mode",
"options": "Polling\nWebsocket"
}
],
"hide_toolbar": 1,
"index_web_pages_for_search": 1,
"is_virtual": 1,
"issingle": 1,
"links": [],
"modified": "2024-04-18 17:44:06.856892",
"modified": "2024-04-18 18:11:05.830332",
"modified_by": "Administrator",
"module": "Desk",
"name": "System Health Report",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Basic system health check report to see how everything on site is functioning in one single page.
Metrics:
- [ ] Background jobs, workers and scheduler summary, queue stats
- [x] Background jobs, workers and scheduler summary, queue stats
- [ ] SocketIO works (using basic ping test)
- [ ] Email queue flush and pull
- [ ] Error logs status
Expand Down Expand Up @@ -42,6 +42,8 @@ class SystemHealthReport(Document):
background_workers: DF.Table[SystemHealthWorkers]
queue_status: DF.Table[SystemHealthQueue]
scheduler_status: DF.Data | None
socketio_ping_check: DF.Literal["Fail", "Pass"]
socketio_transport_mode: DF.Literal["Polling", "Websocket"]
total_background_workers: DF.Int
# end: auto-generated types

Expand Down
4 changes: 4 additions & 0 deletions realtime/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ function frappe_handlers(socket) {
});
};

socket.on("ping", () => {
socket.emit("pong");
});

socket.on("doctype_subscribe", function (doctype) {
socket.has_permission(doctype).then(() => {
socket.join(doctype_room(doctype));
Expand Down

0 comments on commit 023297b

Please sign in to comment.