Killing it softly

A question came up on how to end an UrbanCode Deploy application process quickly when any one of many component processes executing in parallel fails.

For example consider the following (very simple) application process where the processes for two different components are kicked off in parallel. We want the whole process to be stopped  – including any already executing component processes – as soon as the process for component 1 fails.


At first I thought the “Fail Fast” option would do the job.


However the Fail Fast only “does not start more processes after one process fails.” which means that any already executing processes will still be executed.

So a bit of API digging uncovered getApplicationProcessExecution and cancelWorkflow. getApplicationProcessExecution returns a process request’s activity trace (executing workflow) given a request identifier. We can then extract and pass the identifier of the workflow trace to cancelWorkflow to kill it.

Here’s a generic process that uses the two API calls.


The “get workflow ID” step uses the UCD CLI client to invoke getApplicationProcessExecution with the request ID passed in as a parameter to the process.


We use a post-processing script for the above step that registers a regex scanner that finds “workflowTraceId” in the output, throws out the comma at the end and puts the work flow trace identifier into a property called “workflowTraceId”.

var exit = properties.get('exitCode');
scanner.register("workflowTraceId", function(lineNumber, line) {
     var res = line.slice(0,-1)
     var workflowTraceId = res.split(":").pop();
     properties.put('workflowTraceId', workflowTraceId);
if (exit == 0) {
    properties.put('Status', 'Success');
else {
     properties.put('Status', 'Failure');

The cancelWorkflow step uses the value of the “workflowTraceId” property from the previous step to execute the cancelWorkflow CLI command.


Now all that’s required is to incorporate the generic process into the application process so it will be invoked when the component process fails.


The “die now” step passes the value of the current request identifier “${}” to the generic process.


Here’s what an execution of the application process – with an induced failure of the component process – would look like.


So one rather simple way to abort an UrbanCode Deploy application process. It goes without saying that while it meets a particular requirement, a hard and sudden death for a possibly complex process like this may not always be the best thing to do. Consider killing it softly before resorting to brute force.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s