zumult-org / zumultapi

1 stars 0 forks source link

Configuration.xml should not be used in the web application #169

Open EleFri opened 11 months ago

EleFri commented 11 months ago

Backend and frontend should have different configuration files as they should be separate projects in the future.

berndmoos commented 10 months ago

I did some googling, e.g.:

From what I understand, it is best if the configuration file is completely outside the application (i.e. it is part of neither the frontend nor the backend). It is then possible to deploy the same code (WARs etc) on all machines.

The question is then: How does the application know where the config file sits?

In one approach, the config file is placed at a hard-coded path (e.g. /etc/zumult-config.xml on a Unix system). I do not like that because I can't see how it could work across different OS, or how it would work if a sys-admin is not okay with putting something at that particular place.

In another approach, a system variable with a fixed name will contain the path to the config file. Let's say we are on a Windows machine, and we put configuration.xml under c:\mypath. We use ZUMULT_CONFIG_PATH as the name for the system variable. So we do (in a command shell):

setx ZUMULT_CONFIG_PATH c:\mypath\configuration.xml /m

(The command line will have to be run with admin privileges to achieve this)

Once that is done, configuration.xml can be modified, the application redeployed etc. as we please.

Nothing needs to be done in the application code, once we have agreed on the name of the variable. The config file can then be accessed like so:

static final String KEY = "ZUMULT_CONFIG_PATH";
String configPath = System.getEnv(KEY);
File configFile = new File(configPath);
// ... do something with the config file

I will try to implement this in a new branch. @EleFri : please object if you think it is not a good idea :-)

berndmoos commented 10 months ago

image

image

berndmoos commented 8 months ago

Changed this as described above.

berndmoos commented 6 months ago

The current approach does not work if two different applications sit on the same system. Reopening this to think about it...