Details
Assignee
UnassignedUnassignedReporter
JPJPLabels
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Priority
New
Details
Details
Assignee
Unassigned
UnassignedReporter
JP
JPLabels
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Priority
Created 6 December 2018 at 22:37
Updated 4 June 2020 at 09:39
I'm using cfexecute to hand off tasks to CommandBox. These tasks need to run asynchronously, but I'm unable to reliably detect that the hand off from Lucee to the CLI was successful due to some limitations I'm seeing with cfexecute. Basically, during the hand off, I need to detect when cfexecute is unable to create the process for the command. I am not worried about errors that are generated during the execution of the command. Since the tasks are run asynchronously, error handling is done inside the command itself.
To execute a command asynchronously, cfexecute allows me to set timeout to 0 (or a small value) and then terminateontimeout=false, which means that the process will not be terminated when the timeout is reached. However, when I set timeout=0 and terminateontimeout=false, cfexecute does not throw any errors, even when the command cannot be executed.
As a workaround, I set the timeout=5, which throws an exception (with the message "Error invoking external process") if the command can't be executed, but it will also throw an exception when the timeout of 5 seconds is reached (which I don't care about because I want my commands to run asynchronously). So at least I can catch errors when there's a problem with the command, but I have to ignore timeout exceptions. Detecting when there's a timeout error is not as straightforward as I wish it were. The error message is the only thing that tells me it's a timeout error, so I have to parse it for the words "timeout" and "expired" while also checking the amount of time that cfexecute ran. It would be better if the error type was "timeout" or something like that.
Ideally, I would set timeout=0 and terminateontimeout=false, AND ALSO get an exception if the command cannot be run.
I also think cfexecute needs to return additional information, including at least a process ID, and anything else that might be relevant, like an error code. Right now, the only thing being returned are stdout and errout strings, which have obvious limitations. A way to accomplish this would be to add support for an additional argument that would specify the name of the variable to use for sending back some additional information.
Better yet, maybe there could be a new Lucee function that could be called instead of invoking cfexecute... something like:
Then to call it: