Skip to content

Commit

Permalink
Return version via API call
Browse files Browse the repository at this point in the history
* Update the /api/config API call to also return the current version.
* More doc updates.
  • Loading branch information
comstud committed Mar 14, 2024
1 parent b30ccfe commit 090e3d2
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
10 changes: 5 additions & 5 deletions docs/API.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
13 changes: 13 additions & 0 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
12 changes: 9 additions & 3 deletions httpserver/api_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}

0 comments on commit 090e3d2

Please sign in to comment.