Coder Social home page Coder Social logo

Comments (11)

johnseekins-pathccm avatar johnseekins-pathccm commented on June 1, 2024 1

That's excellent. I think I'll steal that little script if that's okay.

Are there any docs that indicate Hubot's default server/port config? I didn't see any.

from hubot.

johnseekins-pathccm avatar johnseekins-pathccm commented on June 1, 2024 1

Ah! That would explain it. Thanks for all the help, @joeyguerra .

from hubot.

joeyguerra avatar joeyguerra commented on June 1, 2024

Not that I know of. What are you thoughts?

from hubot.

joeyguerra avatar joeyguerra commented on June 1, 2024

I just remembered. I replaced the logger with Pino, which outputs logs to stdout in JSON for this situation. Hope that helps.

from hubot.

johnseekins-pathccm avatar johnseekins-pathccm commented on June 1, 2024

The logs are nice, yes. But what I'm interested in is a way to introspect into the service and know whether or not it's running.
A common pattern is curl -Ss localhost:80/healthz and get a 200 response.

The reason I'm looking for something like this is because in containerized environments, it essentially impossible to just run (e.g.) ps aux | grep hubot to tell if a service is running.

from hubot.

joeyguerra avatar joeyguerra commented on June 1, 2024

Now that you mention it, I always have a script that responds to /healthz.

there’s also the hubot-diagnostics module that responds to messages. These are the only patterns I’ve seen used thus far.

I can add some additional diagnostics to hubot-diagnostics. Do you have any suggestions?

from hubot.

johnseekins-pathccm avatar johnseekins-pathccm commented on June 1, 2024

Tell me about your "script that responds to /healthz". When I was initially running hubot, it didn't seem to have an open port at all...I'd be happy to leverage a external-script for this if that's the right pattern!

from hubot.

joeyguerra avatar joeyguerra commented on June 1, 2024

Hubot starts an Express web service on port 8080 (http://localhost:8080) by default. You can disable the web service by setting the HUBOT_HTTPD environment variable to false.

The port can be defined with the PORT environment variable.

I create a file in the scripts directory called HealthZ.mjs with the following contents:

// Description:
// Listens to /healthz for k8s deployment.
//
// Dependencies:
//
// Configuration:
//
// Notes:
//
// Author:
//   Joey Guerra

export default robot => {
    robot.router.get('/healthz', (req, resp) => {
        resp.writeHead(200, {'Content-Type': 'text/plain'})
        resp.end(`Hello? Is it me you're looking for?`)
    })
    robot.respond(/helo/i, async res => {
        res.reply('Hi!')
    })
}

Hubot's router variable is the Express application instance, which can be used to set route handlers in scripts via robot.router.

As an example of what can be done, I created a static site generator as a script and built my website with Hubot.

hubot-diagnostics is another technique that I've seen used to introspect the Hubot app.

What do you think?

from hubot.

joeyguerra avatar joeyguerra commented on June 1, 2024

There's documentation for the HTTP Listener. The public website for Hubot docs hasn't been updated to the latest version. We would need someone in Github to update it :(.

from hubot.

technicalpickles avatar technicalpickles commented on June 1, 2024

The only problem with using an HTTP endpoint to monitor, is that it only tells you if the process is up and responding to HTTP requests, but not how well (or not) it has handling chat message. That is the real thing you care about being up.

One approach I've used/seen/thought of to create a room/channel/whatever that another automated services posts a 'heartbeat' chat message. That way, you can add a listener to check for it, and record the last time it was received. That way, you can make an HTTP endpoint that includes the last heartbeat.

from hubot.

johnseekins-pathccm avatar johnseekins-pathccm commented on June 1, 2024

@technicalpickles You're absolutely right that an HTTP monitor isn't perfect. It is useful for general "is this service even responding?" test. A full validation of Hubot being functional it is definitively not. But it does give me some certainty that Hubot is at least running.

from hubot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.