CatalogueOfLife / backend

Complete backend of COL ChecklistBank
Apache License 2.0
15 stars 11 forks source link

Service depends on itself for startup #1342

Closed MattBlissett closed 3 months ago

MattBlissett commented 3 months ago

During startup:

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:225)
        at com.google.gson.Gson.fromJson(Gson.java:991)
        at com.google.gson.Gson.fromJson(Gson.java:956)
        at com.google.gson.Gson.fromJson(Gson.java:905)
        at com.google.gson.Gson.fromJson(Gson.java:876)
        at org.gbif.nameparser.ParserConfigs.loadFromCLB(ParserConfigs.java:129)
        at life.catalogue.WsServer.run(WsServer.java:262)
        at life.catalogue.WsServer.run(WsServer.java:108)

It tries to load configuration from https://api.checklistbank.org/parser/name/config?limit=1000, but this is provided by this service.

I have hacked the Varnish configuration to allow it to start up:

sub recv_api {
  # To allow loading this during startup
  if (req.url ~ "^/parser/name/config") {
    return(synth(898, "Not yet available"));
  }

  ...
}

...

vcl_synth {
  ...

  # Provide configuration even if the webservice is down.
  if (resp.status == 898) {
    set resp.reason = "OK";
    set resp.status = 200;
    set resp.http.Content-Type = "application/json";
    set resp.body = std.fileread("/home/col/bin/configs/NameParserCLB.json");
    return(deliver);
  }
}

I've left this configuration in place (though not committed) in case another restart is necessary.

NameParserConfig.json

mdoering commented 3 months ago

Move the name parser config loading to after server startup: https://github.com/CatalogueOfLife/backend/commit/7e603d8387eb33102aa603e50df85204868eebf0