2 minute readAutomation

ecdaemon is a "wrapper" program that can be used to start another program from a CloudBees CD/RO job step—the "started" program will run as a daemon process. The CloudBees CD/RO agent uses the facilities of the underlying operating system to make sure the process runs in a separate process group on a UNIX-based system, or outside of the normal "Windows Job" grouping in a Windows system. In either case, the CloudBees CD/RO agent does not treat the process as one it should wait for or one it should try to "kill" if CloudBees CD/RO needs to abort the step.

Use cases

  • ecdaemon is useful in the case where you are trying to deploy a "server-style" program in a CloudBees CD/RO step. You do not want CloudBees CD/RO to wait for that step to complete because it may run continuously, but you do want CloudBees CD/RO to start the server program and then continue on to the next step.

  • ecdaemon is useful if you want to "pre-load" some type of background process.

ecdaemon launches the command and exits. Optionally, it sets a property in CloudBees CD/RO with the pid of the program it spawned to make it possible for a later step to "kill" the daemonized program if desired.

For example: ecdaemon c:/install.exe a b c

Command-line parsing

ecdaemon supports the standard UNIX-style -- flag to indicate there are no more ecdaemon options and all subsequent options should be treated as simple arguments to the command. This is particularly important for commands that themselves take ` '--' ` arguments.

For example:

ecdaemon /usr/bin/myserver --config /etc/myserver.conf

will not run properly because ecdaemon will attempt to parse the --config option instead of passing it to the myserver program. The correct way to invoke `ecdaemon ` in this case is:

ecdaemon — /usr/bin/myserver --config /etc/myserver.conf

If you want to store the daemonized processs pid in a property, do so as follows:

ecdaemon --pidProperty /myJob/serverPid — /usr/bin/myserver --config /etc/myserver.conf

As a daemon process, any output goes to /dev/null, therefore no output file is generated.

ec-perl considerations

Use the perl system () call to start ecdaemon. The system () returns an exit status, "backticks" capture and return output that waits for the daemonized command to complete on Windows, and exec never returns at all if it is successful.