Allessio-

Thanks again…
I made some additional progress, but it does seem that there is some limitation 
to the files that can be configured in this way.  Please see me latest 
responses below.

Thanks
-Tim

From: Alessio Fabiani [mailto:[email protected]]
Sent: Monday, March 20, 2017 2:03 PM
To: Keane, Tim <[email protected]>
Cc: Alessio Fabiani <[email protected]>; 
[email protected]
Subject: Re: [Geoserver-users] spring PropertyPlaceholderConfigurer for data 
directory files?

Hi Tim,
please see responses below

On Mon, Mar 20, 2017 at 6:26 PM, Keane, Tim 
<[email protected]<mailto:[email protected]>> wrote:
Alessio-

Thank you very much.  This is definitely what I am after.  I just have a couple 
of points that maybe you can clarify for me:


1.        It appears that the properties in geoserver-environment.properties 
can only be applied to configuration in data_dir/workspaces such as 
datastore.xml and coveragestore.xml files, but not other configuration like 
data_dir/logging.xml, data_dir/gwc/geowebcache.xml, or 
data_dir/security/usergroup/default/users.xml – is this correct?

It should work also on other catalog settings, not only on catalog. At least 
settings accessible from the UI. Did you already tried it on other settings?

I have tried the following:

set datastore.basemap.host=dbhost
set datastore.basemap.passwd=****
set coveragestore.coast.url=file:///D:/coast-tiff-optimized
set logging.level=VERBOSE_LOGGING.properties
geowebcache.wmsUrl=http://loadblancer-vip/geoserver/wms/

set JAVA_OPTS=%JAVA_OPTS% -DALLOW_ENV_PARAMETRIZATION=true

this works fine for my datastore.xml and coveragestore.xml

fails to set the property for in logging.xml

<logging>
  <level>${logging.level}</level>
  <stdOutLogging>false</stdOutLogging>
</logging>

20 Mar 15:49:12 WARN [geoserver.logging] - log4jConfigFile '${logging.level}' 
couldn't be found in the data dir, so GeoServer will install the various 
logging config file into the data dir, and then try to find it again.
20 Mar 15:49:12 WARN [geoserver.logging] - Still couldn't find log4jConfigFile 
'${logging.level}'.  Using DEFAULT_LOGGING.properties instead.

In production we have a cluster in which gwc requests to /geoserver/gwc are 
directed back to a load balancer for their WMS requests /geoserver/wms and this 
is why I am also trying to externalize the wmsUrl property in geowebcache.xml, 
however no success on this either:

2017-03-20 15:41:09,547 ERROR [seed.MTSeeder] - Malformed URL: 
${geowebcache.wmsUrl}? no protocol: ${geowebcache.wmsUrl}?
org.geowebcache.GeoWebCacheException: Malformed URL: ${geowebcache.wmsUrl}? no 
protocol: ${geowebcache.wmsUrl}?
     at 
org.geowebcache.layer.wms.WMSHttpHelper.makeRequest(WMSHttpHelper.java:118)



2.       It also looks like according to the comment in the source code for 
GeoServerEnvironment.java that System variables should also work, however 
neither setting them as System Environment variables or setting them in 
JAVA_OPTS seemed to work – only placing the geoserver-environment.properties in 
the data directory worked. 
https://github.com/geoserver/geoserver/blob/0054d601f5283fbde087bb253286e9512185d998/src/platform/src/main/java/org/geoserver/platform/GeoServerEnvironment.java#L153

That's strange. From what I can see here  
https://github.com/geoserver/geoserver/blob/0054d601f5283fbde087bb253286e9512185d998/src/platform/src/main/java/org/geoserver/platform/GeoServerEnvironment.java#L129
 it first searches for the property on System and if not null is uses it. You 
may try to rise up the log level and see if you find the line "Could not access 
system property ..."

After a more methodical approach I can get this to work with env var, java 
options or properties file

Ideally I would like to be able to externalize the data directory using the env 
var GEOSERVER_DATA_DIR and also any property contained within config files 
found in the data directory, allowing for the same war file to be deployed 
across environments.

This feature should be able to parametrize almost all config files. If someone 
is not resolved correctly it may be either an issue or not handled by the code.

If you have a very specific use case, you might also consider to backup and 
restore the configuration parametrized and implement special extensions that 
mangle the data dir like we did in this example for the ImageMosaics

https://github.com/geoserver/geoserver/blob/55c4740060eb2b8809ae935a510ac83eeb923313/src/community/backup-restore/extension/src/main/java/org/geoserver/backuprestore/imagemosaic/reader/ImageMosaicAdditionalResourceReader.java

Notice that the backup and restore zip files may be also streamed via REST. 
That way you can easily implement scripts to deploy configurations remotely.

 I will have a look at the extension and experiment with backup and restore


Thanks
-Tim


From: Alessio Fabiani 
[mailto:[email protected]<mailto:[email protected]>]
Sent: Monday, March 20, 2017 11:39 AM
To: Keane, Tim <[email protected]<mailto:[email protected]>>
Cc: 
[email protected]<mailto:[email protected]>
Subject: Re: [Geoserver-users] spring PropertyPlaceholderConfigurer for data 
directory files?

Hi Tim,
during the work for the Backup & Restore plugin for GeoServer, we had the 
chance to implement also the possibility for GeoServer of externalize catalog 
parameters into a ".properties" file placed on the GeoServer Data Directory.
Hopefully this may help you.

Some more details and a small example on how to use it can be found here

http://docs.geoserver.org/latest/en/user/community/backuprestore/configtemplate.html

Please, notice that the documentation is a bit misleading. You won't need to 
install also the Backup & Restore plugin, this functionality is already 
available on GeoServer.

Let me know how it goes and if you need further details/help on this.

Cheers,
Alessio Fabiani.


Best Regards,
Alessio Fabiani.

==
GeoServer Professional Services from the experts!
Visit http://goo.gl/it488V for more information.
==

Ing. Alessio Fabiani
@alfa7691
github<https://github.com/afabiani?tab=overview>
Founder/Technical Lead

GeoSolutions S.A.S.
Via di Montramito 3/A
55054  Massarosa (LU)
Italy
phone: +39 0584 962313<tel:0584%20962313>
fax:     +39 0584 1660272<tel:0584%20166%200272>
mob:   +39 331 6233686<tel:331%20623%203686>

http://www.geo-solutions.it<http://www.geo-solutions.it/>
http://twitter.com/geosolutions_it

-------------------------------------------------------


AVVERTENZE AI SENSI DEL D.Lgs. 196/2003

Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i 
file/s allegato/i sono da considerarsi strettamente riservate. Il loro utilizzo 
è consentito esclusivamente al destinatario del messaggio, per le finalità 
indicate nel messaggio stesso. Qualora riceviate questo messaggio senza esserne 
il destinatario, Vi preghiamo cortesemente di darcene notizia via e-mail e di 
procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro 
sistema. Conservare il messaggio stesso, divulgarlo anche in parte, 
distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, 
costituisce comportamento contrario ai principi dettati dal D.Lgs. 196/2003.



The information in this message and/or attachments, is intended solely for the 
attention and use of the named addressee(s) and may be confidential or 
proprietary in nature or covered by the provisions of privacy act (Legislative 
Decree June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in 
accord with its purpose, any disclosure, reproduction, copying, distribution, 
or either dissemination, either whole or partial, is strictly forbidden except 
previous formal approval of the named addressee(s). If you are not the intended 
recipient, please contact immediately the sender by telephone, fax or e-mail 
and delete the information in this message that has been received in error. The 
sender does not give any warranty or accept liability as the content, accuracy 
or completeness of sent messages and accepts no responsibility  for changes 
made after they were sent or for other risks which arise as a result of e-mail 
transmission, viruses, etc.

---------------------------------------------------------------------

On Mon, Mar 20, 2017 at 3:29 PM, Keane, Tim 
<[email protected]<mailto:[email protected]>> wrote:
Is there a mechanism for using a properties file for value substitution into 
all things xml in the data directory? (i.e., datastore.xml, coveragestore.xml, 
users.xml)

________________________________

This e-mail, including any attachments, may be confidential, privileged or 
otherwise legally protected. It is intended only for the addressee. If you 
received this e-mail in error or from someone who was not authorized to send it 
to you, do not disseminate, copy or otherwise use this e-mail or its 
attachments. Please notify the sender immediately by reply e-mail and delete 
the e-mail from your system.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Geoserver-users mailing list
[email protected]<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/geoserver-users


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to