Bug 319360 - "launch" command should support running more than one .launch in parallel
Summary: "launch" command should support running more than one .launch in parallel
Status: REOPENED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Buckminster (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Thomas Hallgren CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 320510 319313
  Show dependency tree
 
Reported: 2010-07-09 06:04 EDT by Markus Kuppe CLA
Modified: 2019-02-25 14:39 EST (History)
2 users (show)

See Also:


Attachments
A new command "bglaunch" which spawns .launch in the background (8.30 KB, application/octet-stream)
2010-07-13 15:36 EDT, Markus Kuppe CLA
no flags Details
Same functionality as the background bundle, but written as a new command in buckminster.core (5.71 KB, patch)
2010-07-21 07:41 EDT, Markus Kuppe CLA
thomas: iplog+
Details | Diff
mylyn/context/zip (4.32 KB, application/octet-stream)
2010-07-21 07:41 EDT, Markus Kuppe CLA
no flags Details
AbstractLaunch patch (13.27 KB, patch)
2010-08-02 10:01 EDT, Markus Kuppe CLA
no flags Details | Diff
merges BackgroundLaunch and Launch (11.52 KB, patch)
2010-08-03 06:17 EDT, Markus Kuppe CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Kuppe CLA 2010-07-09 06:04:35 EDT
For testing purposes it is sometimes required to spawn a host and a consumer in parallel. This should be supported by Bucky by e.g. taking a comma separated listed of .launch files as an argument the launch command.
Comment 1 Markus Kuppe CLA 2010-07-09 07:14:54 EDT
Thinking about it, the host&consumer example might require something more sophisticated/different in that the host process can be seen as a support process for the consumer and thus be taken down once the consumer terminates.
Looking at the current implementation org.eclipse.buckminster.core.commands.Launch.internalRun(IProgressMonitor), this might even be implemented more easily as in this scenario a single process return value is acceptable contrary to the case where two (or more) generic launch configs are executed concurrently.
Comment 2 Markus Kuppe CLA 2010-07-09 07:43:01 EDT
As an alternate implementation strategy, the Job FW might be of interested as it comes with support for rules which in turn might help model support processes.
Comment 3 Markus Kuppe CLA 2010-07-13 15:36:08 EDT
Created attachment 174223 [details]
A new command "bglaunch" which spawns .launch in the background

Terminates the spawned process on System.exit
Comment 4 Markus Kuppe CLA 2010-07-13 16:04:28 EDT
One can see the command in action e.g. as part of the ECF build [0]. [1] shows the use case for "--ignoremissing".

[0] https://build.ecf-project.org/hudson/job/C-HEAD-remoteservice.rosgi.feature/
[1] https://build.ecf-project.org/hudson/job/C-HEAD-discovery.jmdns.feature/
Comment 5 Markus Kuppe CLA 2010-07-21 07:41:10 EDT
Created attachment 174833 [details]
Same functionality as the background bundle, but written as a new command in buckminster.core
Comment 6 Markus Kuppe CLA 2010-07-21 07:41:12 EDT
Created attachment 174834 [details]
mylyn/context/zip
Comment 7 Thomas Hallgren CLA 2010-07-21 09:34:28 EDT
Comment on attachment 174833 [details]
Same functionality as the background bundle, but written as a new command in buckminster.core

Patch applied to helios-maintenance, rev 11513.

Thanks!
Comment 8 Thomas Hallgren CLA 2010-07-21 17:33:30 EDT
-
Comment 9 Achim Demelt CLA 2010-08-02 03:19:08 EDT
I have some comments and questions regarding the new command:

* The BackgroundLaunch command declares its own "-l" argument, but it also calls super.getOptionDescriptors(), so it inherits the "-l" argument from the Launch command. This is redundant.
* In calling super.getOptionDescriptors(), it also inherits the --stdout and --stderr arguments, but it ignores them if they are given. So it is effectively not possible to redirect stdout/stderr for processes launched in the background.
* It replicates some of the logic already found in the Launch command. Adding support for stdout/stderr capture will replicate even more code.

Why did you choose to implement a separate command instead of adding a new flag (--background) to the regular Launch command?  We can also add the --ignoremissing flag. Since we haven't officially relased the BackgroundLaunch command, I think there's still a chance to merge it into the regular Launch command. What do you think?
Comment 10 Thomas Hallgren CLA 2010-08-02 03:34:01 EDT
I think that sounds like a worth while improvement. Markus, what do you think?
Comment 11 Markus Kuppe CLA 2010-08-02 07:43:24 EDT
(In reply to comment #9)

> * The BackgroundLaunch command declares its own "-l" argument, but it also
> calls super.getOptionDescriptors(), so it inherits the "-l" argument from the
> Launch command. This is redundant.

Definitely an inconsistency.

> * In calling super.getOptionDescriptors(), it also inherits the --stdout and
> --stderr arguments, but it ignores them if they are given. So it is effectively
> not possible to redirect stdout/stderr for processes launched in the
> background.

We (ECF) don't need stdout/stderr functionality for a background launch. Do you guys think it's worth keeping?

> * It replicates some of the logic already found in the Launch command. Adding
> support for stdout/stderr capture will replicate even more code.
> 
> Why did you choose to implement a separate command instead of adding a new flag
> (--background) to the regular Launch command?  We can also add the
> --ignoremissing flag. Since we haven't officially relased the BackgroundLaunch
> command, I think there's still a chance to merge it into the regular Launch
> command. What do you think?

I suggest we create a common abstract parent class like AbstractLaunchCommand instead and have both LaunchCommand as well as BackgroundLaunchCommand inherit from it.
Separating background launch and launch buys us the freedom to add parameters that might not make sense for the other one. E.g. what does something like a "keeprunning" flag mean for the regular launch. Additionally it keeps the implementation free from to much control flow.

Btw. IMO "--ignoremissing" should be made available for both bglaunch as well as launch.

If this finds approval by you, I'd be willing to write a new patch.
Comment 12 Achim Demelt CLA 2010-08-02 08:30:42 EDT
IMO, launching a process in the background is not so much different from regular launching. In UNIX terms, it's just about adding the "&" at the end. Everything else, e.g. stdout/stderr redirection is the same in both cases.

As I see it, the only difference code-wise is that the foreground version waits for the processes to finish. If something goes wrong, the launched processes must be terminated before returning from the Launch command. The background version performs process termination in the VM shutdown hook.

Thomas, which version do you prefer?

In either case, a new patch is highly appreciated! I'll reopen the issue to reflect the ongoing work.
Comment 13 Thomas Hallgren CLA 2010-08-02 08:36:02 EDT
(In reply to comment #12)
> Thomas, which version do you prefer?
> 
I'm in favor of one single launch command with a --background option since that seems to cover all needs. It's easier to document and easier to understand.
Comment 14 Markus Kuppe CLA 2010-08-02 10:01:49 EDT
Created attachment 175712 [details]
AbstractLaunch patch

(In reply to comment #13)
> I'm in favor of one single launch command with a --background option since that
> seems to cover all needs. It's easier to document and easier to understand.

But how do you address conflicting/inconsistent parameters between background and regular launch, e.g. "keeprunning"?

Patch that adds: 
- a common superclass AbstractLaunch
- "keeprunning" flag to BackgroundLaunch (untested)
Comment 15 Thomas Hallgren CLA 2010-08-02 11:13:52 EDT
(In reply to comment #14)
> But how do you address conflicting/inconsistent parameters between background
> and regular launch, e.g. "keeprunning"?
> 
Add some code to the already existing consistency check at the beginning of internalPerform, i.e.

if (launchName == null && !ignoreMissing)
     throw new UsageException(Messages.Launch_No_launch_config);
if(keeprunning && !background)
     throw new UsageException(Messages.Launch_keeprunning_only_for_background);
Comment 16 Markus Kuppe CLA 2010-08-02 11:37:23 EDT
(In reply to comment #15)
> Add some code to the already existing consistency check at the beginning of
> internalPerform, i.e.
> 
> if (launchName == null && !ignoreMissing)
>      throw new UsageException(Messages.Launch_No_launch_config);
> if(keeprunning && !background)
>      throw new UsageException(Messages.Launch_keeprunning_only_for_background);


And once more parameters get added to launch the list of conditions will become longer and longer. Not to mention different permutations that might be acceptable.
Anyway, you have a much better perspective WRT maintainability, thus I will rewrite my patch to use a single Launch class (tomorrow).
Comment 17 Markus Kuppe CLA 2010-08-03 06:17:30 EDT
Created attachment 175758 [details]
merges BackgroundLaunch and Launch

Patch does not implement "keeprunning". Need to define the streamlistener behavior first when the background process continues running after the host process terminates.