Is there a "ready" endpoint?

For development purposes, I’m extending the dgraph/standalone image. Here’s a shortened version:

FROM dgraph/standalone:master

COPY startup.sh /.

CMD ["bash", "startup.sh"]

The startup.sh script deploys a schema, with indexes, when dgraph is healthy, after the following command returns “healthy”: curl -s localhost:8080/health | jq -r .[0].status

Sometimes, however, the indexes don’t update and DGraph prints the following log message:

E1005 15:13:20.119947 51 groups.go:255] Error while proposing initial schema: operation opIndexing is already running

Presumably DGraph is healthy, but not ready. Is there a “ready” endpoint I can use?

Hi Sam, you might want to lookup the health endpoint. . In the documented example, the ongoing indexing op is communicated through the health endpoint. Pasting the example here:

{
  "data": {
    "health": [
      {
        "instance": "zero",
        "address": "localhost:5080",
        "version": "v2.0.0-rc1",
        "status": "healthy",
        "lastEcho": 1582827418,
        "group": "0",
        "uptime": 1504
      },
      {
        "instance": "alpha",
        "address": "localhost:7080",
        "version": "v2.0.0-rc1",
        "status": "healthy",
        "lastEcho": 1582827418,
        "group": "1",
        "uptime": 1505,
        "ongoing": ["opIndexing"],
        "indexing": ["name", "age"]
      }
    ]
  }
}

1 Like