Comments (11)
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.
Ah! That would explain it. Thanks for all the help, @joeyguerra .
from hubot.
Not that I know of. What are you thoughts?
from hubot.
I just remembered. I replaced the logger with Pino, which outputs logs to stdout in JSON for this situation. Hope that helps.
from hubot.
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.
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.
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.
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.
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.
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.
@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)
- Periodic unit test failure on Windows related to loading an adapter by file name
- Update the license HOT 6
- hubot-test-helper broke due to change to Robot constructor HOT 5
- Using Organization Scoped packages as adapters
- Roadmap. The march to `v10` HOT 4
- Does `Response.envelope` really need include the `message` object too? HOT 2
- Upgrade from 7 to 9 causes: "Incorrect number of arguments for middleware callback (expected 1, got 3)" HOT 6
- Using async calls in hubot scripts HOT 2
- Switch site to GitHub pages HOT 3
- Hubot doesn't respond to `@Hubot help`
- Web service test fails in Node.js 21 HOT 2
- Update some of the modules in the Hubot ecosystem HOT 1
- The road to v11, let's get Hubot caught up to the latest changes in Javascript and Node.js
- `./bin/hubot --help` doesn't work HOT 1
- Test failing on Windows HOT 1
- CoffeeScript removal is in v10.0.4 HOT 1
- Windows: Unable to load script file HOT 1
- Running hubot -a @hubot-friends/hubot-ms-teams fails HOT 1
- Testing Hubot with Express 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hubot.