Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support redis monitor #2541

Merged
merged 4 commits into from
Jan 14, 2023
Merged

feat: support redis monitor #2541

merged 4 commits into from
Jan 14, 2023

Conversation

long2ice
Copy link
Contributor

@long2ice long2ice commented Jan 5, 2023

⚠️⚠️⚠️ Since we do not accept all types of pull requests and do not want to waste your time. Please be sure that you have read pull request rules:
https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma

Tick the checkbox if you understand [x]:

  • I have read and understand the pull request rules.

Description

Fixes #1376 for redis

Type of change

Please delete any options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • User interface (UI)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Translation update
  • Other
  • This change requires a documentation update

Checklist

  • My code follows the style guidelines of this project
  • I ran ESLint and other linters for modified files
  • I have performed a self-review of my own code and tested it
  • I have commented my code, particularly in hard-to-understand areas
    (including JSDoc for methods)
  • My changes generate no new warnings
  • My code needed automated testing. I have added them (this is optional task)

Screenshots (if any)

Please do not use any external image service. Instead, just paste in or drag and drop the image here, and it will be uploaded automatically.

server/model/monitor.js Outdated Show resolved Hide resolved
@louislam
Copy link
Owner

Uptime Kuma crashed if the target is not a Redis server.

Example: redis://uptime.kuma.pet:443

node:events:491
      throw er; // Unhandled 'error' event
      ^

SocketClosedUnexpectedlyError: Socket closed unexpectedly
    at Socket.<anonymous> (C:\Users\louis\Dropbox\My Projects\uptime-kuma\node_modules\@redis\client\dist\lib\client\socket.js:181:118)
    at Object.onceWrapper (node:events:628:26)
    at Socket.emit (node:events:513:28)
    at TCP.<anonymous> (node:net:298:12)
Emitted 'error' event on Commander instance at:
    at RedisSocket.<anonymous> (C:\Users\louis\Dropbox\My Projects\uptime-kuma\node_modules\@redis\client\dist\lib\client\index.js:360:14)
    at RedisSocket.emit (node:events:513:28)
    at RedisSocket._RedisSocket_onSocketError (C:\Users\louis\Dropbox\My Projects\uptime-kuma\node_modules\@redis\client\dist\lib\client\socket.js:204:10)
    at Socket.<anonymous> (C:\Users\louis\Dropbox\My Projects\uptime-kuma\node_modules\@redis\client\dist\lib\client\socket.js:181:107)
    at Object.onceWrapper (node:events:628:26)
    at Socket.emit (node:events:513:28)
    at TCP.<anonymous> (node:net:298:12)

@long2ice
Copy link
Contributor Author

I test postgres with same operation, which also crashed

@louislam
Copy link
Owner

I test postgres with same operation, which also crashed

Thanks for testing, both may need to fix.

But that is weird, because it should be inside try...catch.

@long2ice
Copy link
Contributor Author

Sorry, my fault, if input error redis conn string, the server even can't startup, I will fix that

@louislam
Copy link
Owner

Just have a quick look, I think the library is not actually a fully await/async library, you still need to add the event handler.
Because of this, I would recommend that you should change the redisPingAsync function to return promise instead of async function. So that it can reject(error) in the event handler.

Also there are 4 more possible events, better add them too for safety.

image

image

@long2ice
Copy link
Contributor Author

fixed

@louislam
Copy link
Owner

Remark for testing:

docker run --rm -p 6379:6379 redis

server/util-server.js Show resolved Hide resolved
@louislam louislam merged commit 6437ef1 into louislam:master Jan 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is mongo db / redis supported?
3 participants