PDA

View Full Version : ExecAction and Unix background processes



ckessel
05-08-2003, 07:14 PM
I'm using ExecAction to execute a script. The script starts another process in the background ala:

$installDir/bin/foobarservice &

The problem is, if I do that the ExecAction will NEVER say it's complete. I've got waitForCompletion true and it just waits forever. If I kill the "foobarservice" process, the ExecAction immediately sees it's done. So I'm positive it's the launching of the background process that's the problem.

How do I get around this? I need to "waitForCompletion" for other reasons, so just setting that to false isn't an option.

Thanks,
Chris

Jeff Dillon
05-08-2003, 10:55 PM
The behavior that you are describing is exactly correct. The reason that it "waits for forever" is because the exec action is waiting on the process foobarservice . The "background" only exists in the context of a shell.

What do you really want to wait for? I don't really understand what you are trying to do.

ckessel
05-09-2003, 09:57 AM
I've got a script that goes something like this:
--------------launchFoobar.sh-----------------
# Launch the service in the background.
foobarService&

# Wait for the service to show up in the process list. WaitForService() is defined elsewhere.
waitForService "foobarService"

# Ok, we know the service is up, exit the script.
exit 0
---------------------------------------

This, of course, works fine when executed from the Unix command line. However, if I execute it from ExecAction the ExecAction hangs, never finishing because of the foobarService that was launched.

I can't run the launchFoobar.sh script in the background (ExecAction.waitForCompletion=false) since I need to know the service has started, which my waitForService() routine handles, before moving on to my next WizardAction.

So, I'm really hosed at this point. :(

Jeff Dillon
05-09-2003, 10:24 AM
One idea would be to seperate this into two sequential exec actions. One exec action would launch the service with waitForCompletion set to false. The next exec action would launch your wait for service script and have wait for completion set to true.

ckessel
05-09-2003, 10:28 AM
Thanks for the suggestion, I hadn't thought of that.

What I did think of was having my script touch a file at the end, then writing a custom bean that waits for a file to exist before moving on.

Unfortunately, neither of these help if the script is a third party script that starts a service. Which is something I'll probably have to deal with, but I'll cross that bridge when I get there.