How to use an environment variable in the odoo.conf - odoo

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

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.

Moqui Config Pulling Machine Environment Variables

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.

Relatively where does solr.data.dir in solrconfig.xml points to?

In all configuration below, a prefix of "solr." for class names
is an alias that causes solr to search appropriate packages,
including org.apache.solr.(search|update|request|core|analysis)
You may also specify a fully qualified Java classname if you
have your own custom plugins.
This is what I found while going through the solrconfig.xml file. But it seems this is defined to point to the respective classes in solr. I know somehow SOLR_HOME is used for solr.data.dir. I have used solr using "start.jar" and also using "solr-**-*.war" on Tomcat. It just works !!! :)
So where does solr.data.dir points to ?
Where exactly is SOLR_HOME is defined ?
So where does solr.data.dir points to?
The dataDir parameter is used to specify the directory for storing all index data. If this directory is not absolute, then it is relative to the directory where you started Solr. If the folder is empty, the new index would be re-created automatically when starting Solr.
Where exactly is SOLR_HOME is defined?
It really depends on operating system and web server used. And it defines the home directory of your Solr.
The most commonly it could be defined either:
in startup files,
using system environment variables, e.g.:
export JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=/opt/solr/example"
during runtime as part of JAVA_OPTS (on Debian, in /etc/default/tomcat7 for instance, format: -Dmy.prop=value),
using System property substitution file (core.properties/solrcore.properties),
using Tomcat Context Configuration (e.g. in conf/Catalina/localhost by solr/home),
per Solr instance in solr.xml (instanceDir).
Best is to specify it explicitly.
You can modify tomcat/bin/catalina.sh to add following JVM option:
-Dsolr.solr.home=/home/mdhussain/solr-test/deployment/solr1
Data directory is relative to solr home, you can override this in solrconfig.xml.
If you are running on a MAC it's default installation directory (including data)
- if installed via maven dependency at least - is in the /var/XXX directory.
cd /var
grep --color -iHrn solr .
Example on my machine for the index data location:
/var/folders/1j/z7f1373977s_qlfvv9t71kmh0000gq/T/solr-7.3.1/solr-7.3.1/server/solr/cores/catalog_reindex/data

Config File without Environment Variable

I don't have permission to create the Environment variable and I want to pass my Config file path and Name using variable.
Can you use one of the other configuration methods (SQL Server or XML)? Since you have file access, using XML seems appropriate.
See the section for "Types of Configurations":
http://msdn.microsoft.com/en-us/library/cc895212.aspx

How do I configure Mercurial to use environment variables in mercurial.ini

How can I modify the mercurial.ini file to include an environment variable such as %userprofile%.
Specific situation:
I am learning to use Mercurial. I have modified the [ui] section of Mercurial.ini (in my home path) to include:
ignore = c:\users\user\.hgignore
Where user is my username literal. The .hgignore file includes filename filters that are used to ignore files during commit. How can I alter it from being the a literal user to an environment variable $user?
It won't interpolate environment variables in the hgrc, but I do believe that tilda expands to your home/profile directory correctly even on windows.
So:
ignore = ~/.hgignore
should work on windows and elsewhere (even the slashes get spun the wrong way automatically for you).
For other variables you'd need to get a little tricker and write a batch/cmd file that does the interpolation in advance and then hands the result off to mercurial for processing.
The mercurial.ini parses the environment variables just fine.
From my mercurial.ini:
[ui]
ignore = %USERPROFILE%/.hgignore
Works like a charm. Windows 7 Ultimate x64, Mercurial 1.5 (binary installation). The hgignore file is honored both my the command line hg.exe, and tortoiseHG.