Skip to content
This repository was archived by the owner on Nov 9, 2022. It is now read-only.

Commit b3c4e9b

Browse files
authored
Merge pull request #760 from divino/Issue-665
Fix #665
2 parents 618ddb2 + 3336eda commit b3c4e9b

File tree

4 files changed

+80
-17
lines changed

4 files changed

+80
-17
lines changed

deploy/default.properties

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,11 @@ http.read-timeout=300
262262
http.retry-delay=15
263263

264264
#
265+
# Application configuration files
266+
#
267+
application-conf-file=src/app/config/config.xqy
268+
265269
# Verified restart config
266270
#
267271
verify_retry_max=5
268-
verify_retry_interval=10
272+
verify_retry_interval=10

deploy/lib/server_config.rb

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -186,22 +186,26 @@ def self.init
186186
sample_properties = "roxy/sample/build.sample.properties"
187187
sample_options = "roxy/sample/all.sample.xml"
188188
sample_rest_properties = "roxy/sample/properties.sample.xml"
189+
sample_app_config = "roxy/deploy/sample/custom-config.xqy"
189190
else
190-
sample_config = ServerConfig.expand_path("#{@@path}/sample/ml-config.sample.xml")
191-
sample_properties = ServerConfig.expand_path("#{@@path}/sample/build.sample.properties")
191+
sample_config = ServerConfig.expand_path("#{@@path}/sample/ml-config.sample.xml")
192+
sample_properties = ServerConfig.expand_path("#{@@path}/sample/build.sample.properties")
192193
sample_options = ServerConfig.expand_path("#{@@path}/sample/all.sample.xml")
193194
sample_rest_properties = ServerConfig.expand_path("#{@@path}/sample/properties.sample.xml")
195+
sample_app_config = ServerConfig.expand_path("#{@@path}/sample/custom-config.xqy")
194196
end
195197

196198
# output files
197199
build_properties = ServerConfig.expand_path("#{@@path}/build.properties")
198200
options_file = ServerConfig.expand_path("#{@@path}/../rest-api/config/options/all.xml")
199201
rest_properties = ServerConfig.expand_path("#{@@path}/../rest-api/config/properties.xml")
202+
app_config = ServerConfig.expand_path("#{@@path}/../src/config/config.xqy")
200203

201204
# dirs to create
202205
rest_ext_dir = ServerConfig.expand_path("#{@@path}/../rest-api/ext")
203206
rest_transforms_dir = ServerConfig.expand_path("#{@@path}/../rest-api/transforms")
204207
options_dir = ServerConfig.expand_path("#{@@path}/../rest-api/config/options")
208+
config_dir = ServerConfig.expand_path("#{@@path}/../src/config")
205209

206210
# get supplied options
207211
force = find_arg(['--force']).present?
@@ -258,6 +262,10 @@ def self.init
258262
# Update properties file to set server-version to value specified on command-line
259263
properties_file.gsub!(/server-version=6/, "server-version=#{server_version}")
260264

265+
if ["rest", "bare"].include? app_type
266+
properties_file.gsub!(/application-conf-file=src\/app\/config\/config.xqy/, 'application-conf-file=src/config/config.xqy')
267+
end
268+
261269
# save the replacements
262270
open(build_properties, 'w') {|f| f.write(properties_file) }
263271
end
@@ -271,6 +279,11 @@ def self.init
271279
copy_file sample_rest_properties, rest_properties
272280
end
273281

282+
if ["rest", "bare"].include? app_type
283+
FileUtils.mkdir_p config_dir
284+
copy_file sample_app_config, app_config
285+
end
286+
274287
target_config = ServerConfig.expand_path(ServerConfig.properties["ml.config.file"])
275288

276289
if !force && !force_config && File.exists?(target_config)
@@ -1905,8 +1918,7 @@ def deploy_modules
19051918
def deploy_src
19061919
test_dir = @properties['ml.xquery-test.dir']
19071920
xquery_dir = @properties['ml.xquery.dir']
1908-
# modules_db = @properties['ml.modules-db']
1909-
app_config_file = File.join xquery_dir, "/app/config/config.xqy"
1921+
app_configs = @properties['ml.application-conf-file']
19101922
test_config_file = File.join test_dir, "/test-config.xqy"
19111923
load_html_as_xml = @properties['ml.load-html-as-xml']
19121924
load_js_as_binary = @properties['ml.load-js-as-binary']
@@ -1933,6 +1945,7 @@ def deploy_src
19331945

19341946
end
19351947

1948+
total_count = 0
19361949
modules_databases.each do |dest_db|
19371950
if dest_db == "filesystem"
19381951
logger.info "Skipping deployment of src to #{dest_db}.."
@@ -1941,7 +1954,6 @@ def deploy_src
19411954

19421955
ignore_us = []
19431956
ignore_us << "^#{test_dir}.*$" unless test_dir.blank? || deploy_tests?(dest_db)
1944-
ignore_us << "^#{app_config_file}$"
19451957
ignore_us << "^#{test_config_file}$"
19461958
ignore_us << "^#{folders_to_ignore}$" unless folders_to_ignore.blank?
19471959

@@ -1956,7 +1968,34 @@ def deploy_src
19561968
src_permissions.flatten!
19571969
end
19581970

1959-
@logger.debug("source permissions: #{src_permissions}")
1971+
@logger.debug "source permissions: #{src_permissions}"
1972+
if app_configs.present?
1973+
logger.debug "Deploying application configurations"
1974+
1975+
app_configs.split(',').each do |item|
1976+
buffer = File.read item
1977+
replace_properties(buffer, File.basename(item))
1978+
1979+
item_name = item
1980+
prefix = '/'
1981+
if item_name === 'src/app/config/config.xqy'
1982+
item_name = '/config.xqy'
1983+
ignore_us << '/app/config/config.xqy'
1984+
prefix = 'app/config/'
1985+
elsif item.start_with?("src/")
1986+
item_name = '/' + item[4, item.length]
1987+
ignore_us << item_name
1988+
end
1989+
1990+
logger.debug "deploying application configuration #{item} with name #{item_name} on #{dest_db}"
1991+
total_count += xcc.load_buffer item_name,
1992+
buffer,
1993+
:db => dest_db,
1994+
:add_prefix => File.join(@properties["ml.modules-root"], prefix),
1995+
:permissions => src_permissions
1996+
end
1997+
logger.debug "Done deploying application configurations"
1998+
end
19601999

19612000
total_count = load_data xquery_dir,
19622001
:add_prefix => @properties["ml.modules-prefix"],
@@ -1968,16 +2007,6 @@ def deploy_src
19682007
:load_css_as_binary => load_css_as_binary,
19692008
:permissions => src_permissions
19702009

1971-
if File.exist? app_config_file
1972-
buffer = File.read app_config_file
1973-
replace_properties(buffer, File.basename(app_config_file))
1974-
1975-
total_count += xcc.load_buffer "/config.xqy",
1976-
buffer,
1977-
:db => dest_db,
1978-
:add_prefix => File.join(@properties["ml.modules-root"], "app/config"),
1979-
:permissions => src_permissions
1980-
end
19812010

19822011
if deploy_tests?(dest_db) && File.exist?(test_config_file)
19832012
buffer = File.read test_config_file

deploy/sample/build.sample.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,11 @@ mlcp-vmargs=-Xmx512m
208208

209209
# enable the following to save and upload svn/git commit info upon deploy modules
210210
save-commit-info=false
211+
212+
#
213+
# Application configuration files
214+
#
215+
# Assign a comma separated custom configuration files relative to root folder.
216+
#
217+
# Contents of the files will be replaced with data from the properties files.
218+
application-conf-file=src/app/config/config.xqy

deploy/sample/custom-config.xqy

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(:
2+
Copyright 2012-2015 MarkLogic Corporation
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
:)
16+
xquery version "1.0-ml";
17+
18+
module namespace c = "http://marklogic.com/roxy/application-config";
19+
20+
(: configured at deploy time by Roxy deployer :)
21+
declare variable $c:app-name := "@ml.app-name";
22+

0 commit comments

Comments
 (0)