Content is available under Creative Commons Attribution.


Python deployment automation helper functions built into leroy

Leroy’s built-in python interpreter has some additional functions that we have added to it that are commonly used in deployment automation. The problem we are solving is that when creating automated deployments, it is not enough to simply stop and start services. We must also loop and check if services are in-fact started or stopped. This action causes redundant scripting. Leveraging the embedded python interpreter in each agent, building such functions were fairly easy to make. The functions we have created are as follows:

checkForPid and checkForNotPid are used when we know the PID of the service that we have started or killed and we want to know if it has in-fact started, or died.

checkPortListening and checkPortNotListening is when we know what TCP port a given service will be listening on and we want to confirm if it has in-fact started or stopped.

checkHttpString and checkHttpNotString are used when we start a service that presents some web / http type interface. With it, we can poll this url for an amount of time to check if a string or perhaps 1 of 2 strings exist in the web page. This is most commonly used in post-deployment checks to ensure that an application has completely deployed. A great way to take advantage of this is to develop a special url in your application that performs internal checks and produces a unique string on success.

checkRunningLogForStrings is a very special function that we welcome as a nice cross platform utility. This works like you are performing a “tail -f” on a running log and we stop when we see a special string. Certain JBoss applications would enjoy using such a mechanism for example.

In order to make use of any of these functions we need to import Leroy inside our workflow first, here’s an example:


Leave a Reply

by: Epic Force