Search code examples
marklogicml-gradle

Fully disable REST endpoint creation in ml-gradle for MarkLogic


I have been working through building configuration files from a MarkLogic instance to deploy via ml-gradle. I would like to fully disable the REST endpoint at 8003. I'm using ml-gradle version 2.7.0. I was able to gather most of my configuration using gradle mlExportResources.

In my gradle.properties, I've added

mlNoRestServer=true

my build.gradle file is

plugins {
  id "com.marklogic.ml-gradle" version "2.7.0"
  id "net.saliman.properties" version "1.4.6"
}
ext {
    mlAppConfig {
        modulesDatabaseName = "my-modules"
        contentDatabaseName = "my-documents"
        createTriggersDatabase = false
    }

    // Here's an example of not creating a REST API server at all - just remove the command
    mlAppDeployer.getCommands().remove(mlAppDeployer.getCommand("DeployRestApiServersCommand"))

}

The deployment looks ok until it reaches the REST stage. Even given the configuration, it is still referring to port 8003.

13:03:10.226 [INFO] [org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor] Initializing ExecutorService 
13:03:10.227 [INFO] [com.marklogic.client.modulesloader.impl.DefaultModulesLoader] Writing REST server configuration
13:03:10.227 [INFO] [com.marklogic.client.modulesloader.impl.DefaultModulesLoader] Default document read transform: null
13:03:10.227 [INFO] [com.marklogic.client.modulesloader.impl.DefaultModulesLoader] Transform all documents on read: false
13:03:10.228 [INFO] [com.marklogic.client.modulesloader.impl.DefaultModulesLoader] Validate query options: true
13:03:10.228 [INFO] [com.marklogic.client.modulesloader.impl.DefaultModulesLoader] Validate queries: true
13:03:10.228 [INFO] [com.marklogic.client.modulesloader.impl.DefaultModulesLoader] Output debugging: false
13:03:10.228 [INFO] [com.marklogic.client.impl.ServerConfigurationManagerImpl] Writing server configuration
13:03:10.229 [DEBUG] [com.marklogic.client.impl.JerseyServices] Putting config/properties/null
13:03:10.229 [DEBUG] [org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager] Get connection: {}->http://localhost:8003, timeout = 0
13:03:10.230 [DEBUG] [org.apache.http.impl.conn.tsccm.ConnPoolByRoute] [{}->http://localhost:8003] total kept alive: 0, total issued: 0, total allocated: 0 out of 200
13:03:10.230 [DEBUG] [org.apache.http.impl.conn.tsccm.ConnPoolByRoute] No free connections [{}->http://localhost:8003][null]
13:03:10.230 [DEBUG] [org.apache.http.impl.conn.tsccm.ConnPoolByRoute] Available capacity: 100 out of 100 [{}->http://localhost:8003][null]
13:03:10.231 [DEBUG] [org.apache.http.impl.conn.tsccm.ConnPoolByRoute] Creating new connection [{}->http://localhost:8003]
13:03:10.232 [DEBUG] [org.apache.http.impl.conn.DefaultClientConnectionOperator] Connecting to localhost:8003
13:03:10.233 [DEBUG] [org.apache.http.impl.conn.DefaultClientConnection] Connection org.apache.http.impl.conn.DefaultClientConnection@9770e0c closed
13:03:10.233 [DEBUG] [org.apache.http.impl.conn.DefaultClientConnection] Connection org.apache.http.impl.conn.DefaultClientConnection@9770e0c shut down
13:03:10.233 [DEBUG] [org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager] Released connection is not reusable.
13:03:10.233 [DEBUG] [org.apache.http.impl.conn.tsccm.ConnPoolByRoute] Releasing connection [{}->http://localhost:8003][null]
13:03:10.233 [DEBUG] [org.apache.http.impl.conn.DefaultClientConnection] Connection org.apache.http.impl.conn.DefaultClientConnection@9770e0c closed
13:03:10.233 [DEBUG] [org.apache.http.impl.conn.tsccm.ConnPoolByRoute] Notifying no-one, there are no waiting threads
13:03:10.233 [INFO] [com.marklogic.client.impl.DatabaseClientImpl] Releasing connection
13:03:10.233 [DEBUG] [com.marklogic.client.impl.JerseyServices] Releasing connection
13:03:10.233 [DEBUG] [org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter] Removed task artifact state for {} from context.
13:03:10.233 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':mlDeployApp'
13:03:10.233 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] :mlDeployApp FAILED
13:03:10.234 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :mlDeployApp (Thread[Daemon worker Thread 11,5,main]) completed. Took 3 mins 12.831 secs.
13:03:10.234 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationWorkerRegistry] Worker root.3 completed (0 in use)
13:03:10.234 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[Daemon worker Thread 11,5,main]] finished, busy: 3 mins 12.835 secs, idle: 0.002 secs
13:03:10.235 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
13:03:10.235 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.

What configuration am I missing to not deploy a REST server on port 8003?


Solution

  • As of 2.7.0, you can now set mlNoRestServer=true in gradle.properties to disable REST server creation - https://github.com/marklogic-community/ml-gradle/wiki/Property-reference

    The error above is due to these lines:

    13:03:10.228 [INFO] [com.marklogic.client.impl.ServerConfigurationManagerImpl] Writing server configuration 13:03:10.229 [DEBUG] [com.marklogic.client.impl.JerseyServices] Putting config/properties/null

    Do you have a src/main/ml-modules/rest.properties file? If so, ml-gradle sees it and thinks - I need to send this to /v1/config/properties to update the REST API server, but it doesn't exist, and the error results. My guess is that file exists; try deleting it and running mlDeploy again.