Moqui Config Pulling Machine Environment Variables - moqui

Is there a way to set the database config using environment variables that the host machine has set e.g.
<inline-jdbc pool-minsize="1" pool-maxsize="2">
<xa-properties user="{RDS_USERNAME}" password="{RDS_PASSWORD}"
serverName="{RDS_HOSTNAME}" portNumber="{RDS_PORT}" databaseName="tenantcommon"/>
</inline-jdbc>
This is so that I can commit the database settings without committing the database passwords etc, which is also very useful for CI, staging and production using the same database file but each of them having different environment variables?

The approach Moqui is designed for is to keep multiple runtime conf XML files, like variations on the MoquiStagingConf.xml and MoquiProductionConf.xml files. While these files can be in the runtime directory they don't have to be. In previous versions you had to use a ../foo/etc relative path for it to be outside the runtime dir, but now you can start the path with a forward slash to specify the full path to the runtime conf XML file.
You may have various other settings that vary by environment, more than just DB settings, so this approach handles all of them and you just have one runtime environment variable to set, the conf XML file to use.

Related

Run Time Argumnets in PCF

In order to run the application in my local, i need to provide some VM arguments(basically file path, where it is located). In similar way in PCF also I have to provide those arguments.
currently I am keeping in application.yml file like below.
jaas:
conf: /home/vcap/app/BOOT-INF/classes/nonprod_jaas.conf
krb5:
conf: /home/vcap/app/BOOT-INF/classes/krb5.conf
trustore:
conf: /home/vcap/app/BOOT-INF/classes/kafka_client_truststore.jks
When I deploy the application in PCF, will these files will be read from that location.
Basically I want to know this is correct way or not to provide the arguments in PCF.
how to check whether the file is present in that location, /home/vcap/app/BOOT-INF/classes/
You need to ssh into the container to check the location of the file.
cf ssh appname
In spring, #Value enables the use of the classpath: prefix to resolve the classpath (see this link) https://www.baeldung.com/spring-classpath-file-accessclasspath: It means you need to set this programmatically not via the variables in yml. Then you don't need to provide the path the way you are doing.
Also classpath: is a Spring specific convention, the JVM doesn't understand it which means you cannot use it directly in application.yml file. If you need to set in yml or as environment variable - you need to give it a full or relative path. On PCF, you can use /app or /home/vcap/app (the former is a symlink to the latter) as the path to the root of your application.

BlueZ: Change local storage directory

By default, BlueZ stores its persistent data in /var/lib/bluetooth. This includes controller settings and information about paired devices. However, I'm working in a system where the /var directory is unreliable, so I wonder if there is any way I can change this directory?
I have seen examples where it can be changed during installation, with the "--localstatedir" flag, but I'm looking for a solution that doesn't require reinstallation.
Without reinstalling its not possible. Path is configured at compile time so recompilation and installation is required. You can replace STORAGEDIR macro with string which is read from main.conf to different path at runtime. After modifying these changes you can restart bluetoothd every time you change path then it works.

How to use an environment variable in the odoo.conf

I am trying to use an environment variable in the odoo.conf
file to specify the path where the logs are stored.
So far I have tried:
logfile = ${test.rueda}/odoo.log
But it does not work.
Is there any way to achieve this?
The Odoo configuration files do not support access to environment variables.
I can think of 2 possible approaches:
Use relative paths. The file names in the configuration are relative to the working directory of the Odoo server process. Start the Odoo server in different directories, one for every purpose, and keep the same structure relative to that.
Use environment variables in the command line. When starting the Odoo server, any configuration option can be passed using -- (2 dash signs) as a prefix. In the start script, you can then use environment variables as in any other shell script.
See https://www.odoo.com/documentation/11.0/reference/cmdline.html for details.
For referencing files or path:
When i work without external disk (where i can find my datadir):
i use in odoo config file data_dir = my_absolute_path_in_my_local_disk.
This path have a symbolic redirection to where is my local physical location of my local data directory
When my external disk come back, i change the symbolic link:
my_absolute_path_in_my_local_disk -> my_external_disk_..._data

Change XML configuration path for all packages

I have defined SSIS package configuration to XML and configure it for 50 packages. The xml path for those packages were
H:\SomFolder\Configuration\XMLConfig
but in production server we don't have H: so I have created a folder on D:
D:\Configuration\XMLConfig
How can I change all packages to now refer to new path without opening each and every package and manually configure them?
You have hard-coded the xml config file path in each package and relative folder path of files is same for each package as per my understanding. Simple way is to loop through each ".dtsx" file (SSIS package) and find the string DTS:ConfigurationString="H:\SomFolder\Configuration\XMLConfig and replace it with DTS:ConfigurationString="D:\Configuration\XMLConfig with some simple program. Then, you can open the project\s having these SSIS packages and save it which will be ready to deploy on production.
This is general problem people face while developing the SSIS packages. Better way to avoid this issue is to store the xml file location in environment variable, so that you can keep the config files on different location on different machines and environment variable with same name will be present on those machines with different file location.

How can I make deployed resources editable with Maven 2?

I have a project where I create a JAR which contains a bunch of classes with main() plus a set of scripts which set the environment to invoke them. Most of those are long running processes which log a lot (~10-20GB).
This means I have a pretty complex log4j.xml file which, being in src/main/resources/, goes into the JAR. When something breaks in the production system, I'd like to modify the logging on the fly for a single run.
So I came up with the idea to have a conf/ directory on the production and put that into the classpath, first. Then, I thought that it would be great if M2 would put the config files in there (instead of the JAR). But that would overwrite any manual changes during an automated deployment which I strongly dislike. I'm also not fond of timestamps and things like that.
So my next ideas was this: M2 should leave the config files in the JAR but create copies of the files with the name *.tpl in the conf/ directory. The admin could then copy a template to the basename to override the files in the JARs. .tpl-Files would be overwritten but that wouldn't hurt. Admins would have full control over which version of the log was active and they could run a diff to see whether any important changes were made.
Now the question: Has someone seen a plugin which automates this process? That is which creates a conf/ directory with all or a selected subset of everything in src/main/resources/ and which renames the files?
Best practice in Maven handling config files is to place them in a separate conf directory, and pack them in a binary assembly using the assembly plugin. Placing configuration files, like log4j.xml in the src/main/resources doesn't make sense, since it is not a true application resource, but more of a configuration file.
We cope with the overwriting, by packing the configuration files with the posfix .def. For example: myapp.properties is packed into the assembly as myapp.properties.def. When the person who uses the assembly unpacks it, it will not overwrite his original files. After unpacking he simply merges them by an external tool (we use meld in Fedora Core).
I may be missing something and this doesn't answer directly the question but did you consider producing a zip assembly of the exploded content of required artifacts (to be unzipped on the target environment)?
Sounds like you're attacking the problem the wrong way. Why not just run the application with -Dlog4j.configuration=/some/where/my-log4j.properties? If you want, you can add a command line flag to main() which invokes the PropertyConfigurator directly.