-
-
Notifications
You must be signed in to change notification settings - Fork 79
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
[3.x] HTTP API healthcheck #413
Conversation
Love the idea. I will let the others share their thoughts too. |
I'm working on something simular - but I'm using mode-IPC for it, is gonna be used for GUI |
Discussed with @arik123 earlier on Discord about IPC and the need of having an API server on a bot. The main points were:
The only left issue is the healthcheck functionality. The healthcheck can pass/fail if I either:
I was looking for the TCP or the command execs for healthchecks, but I'm not sure which one to pick or how we can acheive this. The HTTP |
Thanks for the update. You may keep this pull request open so every progress/discussion can be seen here. |
it could be probably implemented such that, it would take near to nothing if not enabled, but then the whole part of GUI that I have planned - Managment of multiple bots would not work |
Oh right true. in that case, probably best to make the GUI a separate app. |
Maybe the API can still exist (and be disabled by default) for non-GUI-based applications, like managing your own bots? |
Yes, sure thing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about setting default port to something random, so there is smaller chance of collision with other programs.
@@ -4,6 +4,7 @@ const { version: BOT_VERSION } = require('../package.json'); | |||
import { getPricer } from '@pricer/pricer'; | |||
import Pricer, { GetPricerFn } from './classes/Pricer'; | |||
import { loadOptions } from './classes/Options'; | |||
import HttpManager from './classes/HttpManager'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about importing only if enabled, to reduce memory usage slightly, but this is not that important
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ES6 and TS don't allow importing with import from
within classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, either use require
or let it be like it is now
Also maybe add some note to the source, that tells everyone about GUI as main API provider. |
Now let say I want to use this and want to check my bot uptime via an API, and I am running my bot on a VPS, I need to type this on my browser URL: right? |
@idinium96 Yes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
roger that 👍
merging before going to bed...
#411 ## Added - Mainly if you're using generic Unusual buy order feature: - ✨option to not automatically add bought Unusual item to the pricelist (usual because buying with Generic Unusual buy order - #412, [Wiki](https://github.com/TF2Autobot/tf2autobot/wiki/Configure-your-options.json-file#--automatic-add-invalid-unusual--)) - @joekiller - new options added: - `pricelist.autoAddInvalidUnusual.enable` (default is `false`) - `sendAlert.receivedUnusualNotInPricelist` (default if `true`) - ✨HTTP API health check (and others in the future - #413, [Wiki](https://github.com/TF2Autobot/tf2autobot/wiki/Configuring-the-bot#api)) - @rennokki - new env variables: - `ENABLE_HTTP_API` (default is `false`) - `HTTP_API_PORT` (default is `3001`) - ✨option to show proper item name in trade/offer summary (with "The", no short - #415, [Wiki](https://github.com/TF2Autobot/tf2autobot/wiki/Configure-your-options.json-file#-trade-summary-settings-)) - @idinium96 - new options added: - `tradeSummary.showProperName` (default is `false`) ## Updates - Partial price update feature (updated #337): - ⛔ do not partial price Mann Co. Supply Crate Key (#407) - @idinium96 - ✅ add an option to exclude items for partial price update (#408, [Wiki](https://github.com/TF2Autobot/tf2autobot/wiki/Configure-your-options.json-file#--partial-price-update--)) - @idinium96 - new options.json property: `pricelist.partialPriceUpdate.excludeSKU` (default is `[]`) - 💅 include name in partial price update summary (#409) - @idinium96 - ⛔ do not perform usual update if grouped (#410) - @idinium96 - 🔨 refactor Bot.ts (#399) - @arik123 - 🔎🔑 keyPrices verification (2) and 🔨 small refactor on Pricelist.ts (#416) - @idinium96 - 🔕 ignore some error on fail action or to accept mobile confirmation (#419) - @idinium96 - 🔨 refactor: use Map and Set (#420) - @idinium96 - 🎨 show amount offering/offered/taking/taken in overstocked/understocked review/trade summary (#421) - @idinium96
The concept of having an API for the bot can ease multiple tasks:
sending commands to the bot via HTTP (opens up new ways of implementing SDKs for tf2autobot, implementable in any language since it's REST)reading information about the BOT, including current item configurations for tradingRoadmap
/health
endpoint for checking readiness/alivenessConfigured items/bots endpoint for reading the configured items and botsTests, lots of testsThe GUI v3 rework already has an entrypoint for the API, so sticking just with healthchecks and uptime should be fine. 👍🏼