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

Lots of cleanup #11

Merged
merged 19 commits into from
Sep 28, 2024
Merged

Lots of cleanup #11

merged 19 commits into from
Sep 28, 2024

Conversation

tiennou
Copy link

@tiennou tiennou commented Sep 28, 2024

I've toyed a bit more with it.

Changes are:

  • It's type-checked with Typescript 🎉. Still a bit bare-bones, but the stuff we really care about is.
  • The whole setup step process is gone; the compose file is now static, with only the .env file and the users.json file needing to be customized. If someone has special needs, all the configs for Grafana & Graphite are still there, they're just mounted directly into their respective containers (meaning apart from the .env file, everything can be tracked and committed.
  • A bug where collected data from multiple shards for one user would possibly get lost as each load from the API would be overwritten by the next one.
  • The users file is now validated as it is loaded, and anything that's missing info will be ignored. Additionally, the host/port configuration for an user is now fully resolved (with the old local server auto-detection happening at that point) based on the type.
  • Users are reloaded every time the cron runs (so every 30s). Given the file is now mounted into the container, this means that edits from outside the container will be picked up automatically without needed a container restart.
  • Streamlined the way users are grouped and checked by the cron task (by host now, instead of type, since that's now always available). This fixes a bug where we'd process a type of user (possibly from different private servers) and ingress the server stats from the first one in the full list (so possibly not the correct server).

I missed the port being hardcoded in the stat-pusher.

This makes it properly go through the environment. The setup harness
will auto-use 10004 if --pushStatusPort is set, otherwise set it to the
specified value.
Instead of having the setup potentially copy over the example user file,
just ask the user to set it up himself. This stops mistakes from
happening with `--force`.

Also mount the file into the container instead of copying it, so that an
update just needs a container restart and not a rebuild. Hence, remove
the rebuilding from the start script and add it as a developer-intended
command to the npm scripts (since the only reason to rebuild would be if
the pushStats scripts is edited).
This moves everything the setup step did to the `.env` & Compose files
into the files themselves, which makes the Compose file fully static,
with the `.env` file in charge of carrying the setup.
This just mounts the config files directly into the containers and
passes the value we wanna tweak through the environment instead.
This saves Grafana from logging errors because the directories don't exist.
There's no .env file in that container, and everything is passed in
by the compose file already.
User loading has been moved to its own file and validated for
correctness; now, an user definition will be complete (there's a valid
username, replaceName, host/port based on type, token/password), so that
the rest of the code can just use those values.

Now each time the cron triggers, the users file is parsed again, and
users marked as type: "private" with nothing else will use a local
Screeps server automatically if found; use an explicit host/port to
make them static.
@pieterbrandsen pieterbrandsen merged commit c5c661e into screepers:master Sep 28, 2024
2 checks passed
@tiennou tiennou deleted the develop branch September 28, 2024 23:48
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.

2 participants