0

We have a number of (developer) existDb database servers, and some staging/production servers.

Each have their own configuration, that are slightly different.

We need to select which configuration to load and use in queries.

The configuration is to be stored in an XML file within the repository.

However, when syncing the content of the servers, a single burnt-in XML file is not sufficient, since it is overwritten during copying from the other server.

For this, we need the physical name of the actual database server.

The only function found, request:get-server-name that is not quite stable since a single eXist server can be accessed through a number of various (localhost, intranet or external) URLs. However, that leads to unnecessary duplication of the configuration, one for each external URL...

(Accessing some local files in the file system is not secure and not fast.)

How to get the physical name of the existDb server from XQuery?

2 Answers2

0

I m sorry but I don't fully understand your question, are you talking about exist's default conf.xml or your own configuration file that you need to store in a VCS repo? Should the xquery be executed on one instance and trigger an event in all others, or just some, or...? Without some code it is difficult to see why and when something gets overwritten.

you could try console:jmx-token which does not vary depending on URL (at least it shouldn't)

Also you might find it much easier to use a docker based approach. Either with multiple instances coordinated via docker-compose or to keep the individual configs from not interfering with each other when moving from dev to staging to production https://github.com/duncdrum/exist-docker

duncdrum
  • 723
  • 5
  • 13
  • use case: sync to folder on machine 1, sync from folder to machine 2 => config xml-s are overwritten in single inst on my exist no console package (2.x; 3 and 4 is so buggy we do not risk the change) yet jmx-token is not the name of the server... docker is fine, but: the various instances are composed of over 10 elements each from different servers, so there is no something like a single "image" (GUI, security data, business data 1 ... business data n, application code etc. all alive on their own servers) – Attila Törcsvári May 24 '18 at 06:35
  • the folder of machine 1 is on an external volume, or inside an eXist collection within its data_directory? Do all instances have access to the same data directory? 2.2 is sort of ancient history i think you have a better chance of getting an answer by posting to exist's hipchat as more people have experience with running old versions there. I think there is a fixable architectural issue, conf.xml resides outside exists data directory so there should be no overwriting when moving from machine1 -> machine2 – duncdrum May 24 '18 at 07:35
  • thanks; all comes from the impossibility of proper GIT ing exist db collections..., nor any sync tool works. console:jmx-token seems empty; my colleague is docker expert and did not propose docker approach (data is to be refreshed on XML element level... not quite containerizable) I hoped exist gives a "who_am_i" easiliy - which seems not the case. – Attila Törcsvári May 24 '18 at 07:42
  • Is there a way to get info from conf.xml in xquery?! – Attila Törcsvári May 24 '18 at 07:44
  • btw. on a 4.1 fresh install jmx-token is empty – Attila Törcsvári May 24 '18 at 07:46
  • your problem sounds very solvable, but hipchat is a better fit for back and forth. I have multiple instances sharing data volumes using docker-compose without problems (although i expect with very high concurrencies that might be different) 4.1 and 5.0 are all about concurrency and there are some old git libraries that should work on 2.2. To get conf.xml data check the system:… module documentation – duncdrum May 24 '18 at 07:46
0

If I understand correctly, you basically want to be able to get the hostname or the IP address of a server from XQuery. If the functions in the XQuery Request module are not doing as you wish, then another option would be to set a Java System Property when starting eXist-db. This system property could be the internal DNS name or IP of your server, for example: -Dour-server-name=server1.mydomain.com

From XQuery you could then read that Java System property using util:system-property("our-server-name").

adamretter
  • 3,885
  • 2
  • 23
  • 43
  • this basically solves the problem. request:get-server-name seem returning the actual external host name not the DB server name. Somewhat strange there is no easier self-reference. It is also all related to access local resources (from the same DB server, same resources must be used no matter if request is from from intranet or internet). – Attila Törcsvári May 24 '18 at 14:20
  • Most of the request module functions just delegate to Java methods on the Java Servlet spec's `HttpServletRequest` so they will ultimately do whatever the Java Servlet specification defines. – adamretter May 25 '18 at 21:52