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

Deployer

Geert edited this page Jun 8, 2017 · 25 revisions

Roxy Deployer is a command line tool for scaffolding and deploying XQuery applications to MarkLogic Server. Help is available by running the ml command with no parameters:

> ml

Environments

The Roxy Deployer handles different environments for you. Most of your configuration will go into deploy/build.properties and deploy/ml-config.xml. When you need to specify different values for different environments, create deploy/{env}.properties and put the environment-specific properties there. For more information, see the Environment Properties page.

Bootstrap

Roxy Deployer can automatically create all your forests, databases, app servers, users, and roles for you. You provide the settings via property files. Roxy deployer uses these values to create the necessary configuration on one or more servers.

Example of bootstrapping to your local box

> ml local bootstrap

You can also deploy to a cluster.

Wipe

You can "uninstall" your application from a MarkLogic server with Roxy Deployer. All traces of your application will be removed from the server.

Example of wiping your application from the dev box

> ml dev wipe

Specifying what to bootstrap or wipe

It is possible to select to only bootstrap or wipe specific parts of a configuration using the "--apply-changes" option. Valid options include all, ssl, privileges, external-security, credentials, mimetypes, groups, amps, tasks, indexes, users, roles, databases, forests and appservers .

Example of selective bootstrapping

./ml local bootstrap --apply-changes=indexes,users,roles

Example of selective wiping

./ml local wipe --apply-changes=databases,forests,appservers

Deploying source code

You can deploy your XQuery modules to a MarkLogic modules database. By default, all files under $roxy/src are deployed except for test files. Test files are only deployed if you have a test environment configured and only for non-production environments.

Example of deploying source code to your development box

> ml dev deploy modules

You can substitute for some special values in your source code when you deploy modules.

Using the filesystem for modules

Many developers prefer using the filesystem for developing on their local systems. Doing so saves the trouble of having to deploy modules between changes. To set this up, edit your deploy/local.properties file (create it if necessary) and set these values:

app-modules-db=filesystem
modules-root=<full path to your code>

For instance:

app-modules-db=filesystem
modules-root=/home/dcassel/git/roxy

Note that if you work on the filesystem, Roxy does not do in-code substitutions (see section above). We recommend using modules databases for remote systems, to make backups and other maintenance tasks easier.

Erasing deployed source code

You can remove all the code from your modules database with a single command. Be warned that this is potentially destructive in the wrong hands.

Example of wiping clean your modules database

> ml local clean modules

Deploying content

You can deploy content to your content database. By default, all files under $roxy/data are deployed.

Example of deploying content to your local database

> ml local deploy content

You can also load content using recordloader or xqsync.

Erasing deployed content

You can remove all the data from your content database with a single command. Be warned that this is potentially destructive in the wrong hands.

Example of wiping clean your content database

> ml local clean content

CPF

You can use Roxy to work with CPF.

Unit Testing

You can invoke your Roxy Unit Tests with the Deployer.

Example of invoking unit tests on your local ML instance

> ml local test

Scaffolding

The Roxy Deployer allows you to easily create code via a handful of scaffolding methods.

Create Controller and View

Requires: app-type = mvc or hybrid You can create a controller and view with Roxy Deployer.

The syntax is as follows:

> ml create controller/function format

Both function and format are optional. If no view is provided Roxy will default to main. If no format is provided then Roxy will default to html. You can skip view creation by specifying format as none

A controller will be created at $roxy/src/app/controllers/$controller.xqy A function matching the name your provided will be created inside of the controller file. A view to render the output in the provided format will be created in $roxy/src/app/views/$controller/$function.$format.xqy

This command is non-destructive. If any of the specified pieces already exist they will be left alone.

Typical example

> ml create search/facets html

creates:
$roxy/src/app/controllers/search.xqy with a facets() function
$roxy/src/app/views/users/facets.html.xqy

Using default format

> ml create search/facets

creates:
$roxy/src/app/controllers/search.xqy with a facets() function
$roxy/src/app/views/users/facets.html.xqy

Using default function and format

> ml create search

creates:
$roxy/src/app/controllers/search.xqy with a main() function
$roxy/src/app/views/users/main.html.xqy

Example with no view

> ml create search/main none

creates:
$roxy/src/app/controllers/search.xqy with a main function

Example of creating a json view

> ml create users/new json

creates:
$roxy/src/app/controllers/users.xqy with a new() function
$roxy/src/app/views/users/new.json.xqy

Create a Model

Requires: app-type = mvc or hybrid You can create a model with Roxy Deployer.

The syntax is as follows:

> ml create model name

This command is non-destructive. If any of the specified pieces already exist they will be left alone.

A model file will be created at $roxy/src/app/models/$name.xqy

Example

> ml create model users-lib

creates:
$roxy/src/app/models/user-lib.xqy

Processing Content

You can use Roxy and Corb together to process content. Once you have bootstrapped, deployed modules, and loaded some data, you can run Corb jobs on those documents like this:

Examples

# Assumes /corb/stuff-uris.xqy and /corb/do-something.xqy exist in your src directory and have been deployed
> ml local corb --uris=/corb/stuff-uris.xqy --modules=/corb/do-something.xqy

# This version will look for a module on the filesystem and install it in your modules database. This is necessary when using --collection, unless /get-uris.xqy is already installed. Yes, it's probably already there because you deployed modules. This is how Corb works. 
> ml local corb --collection=stuff --modules=src/corb/do-something.xqy --install=true

Use "ml corb -h" to see the options.

Clone this wiki locally