From 090e3d247329786d7b9da3e9aba474bbc47da7cd Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Wed, 13 Mar 2024 19:41:15 -0700 Subject: [PATCH] Return version via API call * Update the /api/config API call to also return the current version. * More doc updates. --- README.md | 6 ++++++ docs/API.md | 10 +++++----- docs/FAQ.md | 13 +++++++++++++ httpserver/api_config.go | 12 +++++++++--- 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e5ecf07..0ea9164 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,12 @@ After adding the config to Golbat, restart Golbat to have it take effect. ## pm2 +### Requirements + +You will need to have at least golang 1.22.1 installed. It is rather new as of the time of this writing. You may need to install it manually. See the [instructions and download links](https://go.dev/dl/). + +### Building and starting + 1. `make` 2. `pm2 start ./fletchling --name fletchling -o /dev/null` diff --git a/docs/API.md b/docs/API.md index 71fec94..1728069 100644 --- a/docs/API.md +++ b/docs/API.md @@ -1,17 +1,17 @@ # API -## Get config +## Get config and the version of Fletchling that is running. `curl http://localhost:9042/api/config` ## Reload configuration `curl http://localhost:9042/api/config/reload` (Also supports PUT. You can also send a SIGHUP signal to the process) -## Rerun spawnpoint, area, overlap filtering and reload configuration: -`curl http://localhost:9042/api/config/reload?refresh=1` +## Re-run spawnpoint, area, overlap filtering and reload configuration: +`curl 'http://localhost:9042/api/config/reload?refresh=1'` -## Refresh spawnpoint counts, re-run spawnpoint, area, overlap filtering and reload configuration: -`curl http://localhost:9042/api/config/reload?refresh=1&spawnpoints=all` +## Refresh spawnpoint counts; Re-run spawnpoint, area, overlap filtering and reload configuration: +`curl 'http://localhost:9042/api/config/reload?spawnpoints=all'` (refresh=1 is implied and not required) ## Get all nests `curl http://localhost:9042/api/nests` diff --git a/docs/FAQ.md b/docs/FAQ.md index b96f6d1..5f7ac37 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -9,3 +9,16 @@ After that, every 'rotation_interval_minutes', there's a chance at determining t But it really depends on the number of spawns in each nest. The nesting pokemon will not be determined until there's a sufficient amount of stats. You can `grep NESTING logs/fletchling.log` to easily see nesting pokemon decisions. You may see something like "299:1460". That's dexId:formId and that one happens to be Nosepass normal form. + +## Why does the importer error with something about nests db migrations? + +If there are DB schema changes in a new version of Fletchling, those migrations need to be run. The importer tool will not do these migrations because if old Fletchling is running, it is possible the migrations will break it. So, the importer always checks to make sure the DB is where it should be. If it is not, it means you've not restarting Fletchling yet. Restarting Fletchling will run the DB migrations. Then you may use the importer tool and it won't complain. + +## I ran the importer, but I have no spawnpoint counts in my DB. What gives? + +If nests were actually imported, there's only a couple of reasons why this can be: + +* You forgot to configure the golbat_db section in the config file. +* The spawnpoint DB queries are erroring, possibly due to wrong golbat_db configuration. + +After correcting the above, you can issue the `/api/config/reload?spawnpoints=all` API call to Fletchling to have it recompute everything and reload. diff --git a/httpserver/api_config.go b/httpserver/api_config.go index a632fb6..d201951 100644 --- a/httpserver/api_config.go +++ b/httpserver/api_config.go @@ -9,6 +9,7 @@ import ( "github.com/UnownHash/Fletchling/filters" "github.com/UnownHash/Fletchling/processor" + "github.com/UnownHash/Fletchling/version" ) func (srv *HTTPServer) doDBRefresh(c *gin.Context, allSpawnpoints bool) error { @@ -89,11 +90,16 @@ func (srv *HTTPServer) handleGetConfig(c *gin.Context) { } type getConfigResponse struct { - Config configResponse `json:"config"` + Config configResponse `json:"config"` + Version string `json:"version"` } - var resp getConfigResponse - resp.Config.ProcessorConfig = srv.nestProcessorManager.GetConfig() + resp := getConfigResponse{ + Version: version.APP_VERSION, + Config: configResponse{ + ProcessorConfig: srv.nestProcessorManager.GetConfig(), + }, + } c.JSON(http.StatusOK, resp) }