-
Notifications
You must be signed in to change notification settings - Fork 20
Scheduled Tasks
This page has been started for the 3.10.0 release and will eventually document as many of the features as possible specific to deploying scheduled tasks.
Release 3.10.0 introduces support for deploying multiple scheduled tasks with the same task-path. ml-app-deployer now uses both the task-path and the task-database properties to determine if a task has already been deployed. The thought behind this is that it is very unlikely to want to run the same scheduled task against the database, but at different times. If you do have a need to do so, please create an issue to explain your use case. As a workaround, you can create two separate scheduled task modules that invoke the same library function.
The Manage API for creating a scheduled task accepts a property named "task-host", which must be a host name. But you rarely want to hardcode this, as those names are likely to change across environments.
Support for doing this more easily will soon arrive in a new version of ml-gradle/ml-app-deployer, but in the mean time, you can use a script like one below to fetch the host names and set them as tokens that can be replaced in payload files (this particular script assumes there are at most 3 hosts; you can of course customize this to support any number of hosts).
task setHostTokens {
doLast {
def manageConfig = new com.marklogic.mgmt.ManageConfig(mlHost, 8002, mlUsername, mlPassword)
def hostManager = new com.marklogic.mgmt.resource.hosts.HostManager(new com.marklogic.mgmt.ManageClient(manageConfig));
hostManager.getHostNames().eachWithIndex { hostName, index ->
project.extensions.add("mlHostName" + index, hostName)
}
println "First host: " + project.property("mlHostName0")
}
}
mlDeployApp.dependsOn setHostTokens