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

Commit

Permalink
Merge pull request #760 from divino/Issue-665
Browse files Browse the repository at this point in the history
Fix #665
  • Loading branch information
dmcassel committed Apr 26, 2017
2 parents 618ddb2 + 3336eda commit b3c4e9b
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 17 deletions.
6 changes: 5 additions & 1 deletion deploy/default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,11 @@ http.read-timeout=300
http.retry-delay=15

#
# Application configuration files
#
application-conf-file=src/app/config/config.xqy

# Verified restart config
#
verify_retry_max=5
verify_retry_interval=10
verify_retry_interval=10
61 changes: 45 additions & 16 deletions deploy/lib/server_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,22 +186,26 @@ def self.init
sample_properties = "roxy/sample/build.sample.properties"
sample_options = "roxy/sample/all.sample.xml"
sample_rest_properties = "roxy/sample/properties.sample.xml"
sample_app_config = "roxy/deploy/sample/custom-config.xqy"
else
sample_config = ServerConfig.expand_path("#{@@path}/sample/ml-config.sample.xml")
sample_properties = ServerConfig.expand_path("#{@@path}/sample/build.sample.properties")
sample_config = ServerConfig.expand_path("#{@@path}/sample/ml-config.sample.xml")
sample_properties = ServerConfig.expand_path("#{@@path}/sample/build.sample.properties")
sample_options = ServerConfig.expand_path("#{@@path}/sample/all.sample.xml")
sample_rest_properties = ServerConfig.expand_path("#{@@path}/sample/properties.sample.xml")
sample_app_config = ServerConfig.expand_path("#{@@path}/sample/custom-config.xqy")
end

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

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

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

if ["rest", "bare"].include? app_type
properties_file.gsub!(/application-conf-file=src\/app\/config\/config.xqy/, 'application-conf-file=src/config/config.xqy')
end

# save the replacements
open(build_properties, 'w') {|f| f.write(properties_file) }
end
Expand All @@ -271,6 +279,11 @@ def self.init
copy_file sample_rest_properties, rest_properties
end

if ["rest", "bare"].include? app_type
FileUtils.mkdir_p config_dir
copy_file sample_app_config, app_config
end

target_config = ServerConfig.expand_path(ServerConfig.properties["ml.config.file"])

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

end

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

ignore_us = []
ignore_us << "^#{test_dir}.*$" unless test_dir.blank? || deploy_tests?(dest_db)
ignore_us << "^#{app_config_file}$"
ignore_us << "^#{test_config_file}$"
ignore_us << "^#{folders_to_ignore}$" unless folders_to_ignore.blank?

Expand All @@ -1956,7 +1968,34 @@ def deploy_src
src_permissions.flatten!
end

@logger.debug("source permissions: #{src_permissions}")
@logger.debug "source permissions: #{src_permissions}"
if app_configs.present?
logger.debug "Deploying application configurations"

app_configs.split(',').each do |item|
buffer = File.read item
replace_properties(buffer, File.basename(item))

item_name = item
prefix = '/'
if item_name === 'src/app/config/config.xqy'
item_name = '/config.xqy'
ignore_us << '/app/config/config.xqy'
prefix = 'app/config/'
elsif item.start_with?("src/")
item_name = '/' + item[4, item.length]
ignore_us << item_name
end

logger.debug "deploying application configuration #{item} with name #{item_name} on #{dest_db}"
total_count += xcc.load_buffer item_name,
buffer,
:db => dest_db,
:add_prefix => File.join(@properties["ml.modules-root"], prefix),
:permissions => src_permissions
end
logger.debug "Done deploying application configurations"
end

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

if File.exist? app_config_file
buffer = File.read app_config_file
replace_properties(buffer, File.basename(app_config_file))

total_count += xcc.load_buffer "/config.xqy",
buffer,
:db => dest_db,
:add_prefix => File.join(@properties["ml.modules-root"], "app/config"),
:permissions => src_permissions
end

if deploy_tests?(dest_db) && File.exist?(test_config_file)
buffer = File.read test_config_file
Expand Down
8 changes: 8 additions & 0 deletions deploy/sample/build.sample.properties
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,11 @@ mlcp-vmargs=-Xmx512m

# enable the following to save and upload svn/git commit info upon deploy modules
save-commit-info=false

#
# Application configuration files
#
# Assign a comma separated custom configuration files relative to root folder.
#
# Contents of the files will be replaced with data from the properties files.
application-conf-file=src/app/config/config.xqy
22 changes: 22 additions & 0 deletions deploy/sample/custom-config.xqy
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(:
Copyright 2012-2015 MarkLogic Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
:)
xquery version "1.0-ml";

module namespace c = "http://marklogic.com/roxy/application-config";

(: configured at deploy time by Roxy deployer :)
declare variable $c:app-name := "@ml.app-name";

0 comments on commit b3c4e9b

Please sign in to comment.