Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group stdout together by process #13

Open
cjsfj opened this issue Jan 4, 2018 · 1 comment
Open

Group stdout together by process #13

cjsfj opened this issue Jan 4, 2018 · 1 comment

Comments

@cjsfj
Copy link

cjsfj commented Jan 4, 2018

Thanks again for this library. It's pretty awesome and fulfilling a big need.

After implementing #12, the process output is extremely valuable.

I'm wondering if there is a good method of grouping this output by process (even if it means there is no output until after the process or parent process completes). As we troubleshoot / analyze the output, we find we spend some time sifting through things to see the output from each process together.

I have some hair-brained ideas that involving parsing and looping through the full output and then displaying it, but wanted to see if there were any possibilities that are "more native."

Thanks!

C

@h-bragg
Copy link
Contributor

h-bragg commented Jan 4, 2018

For this you could ignore the in-line stuff, and just print on completion.

For the onSuccess and onFailure callbacks you can just output at that point:

$pool = new Pool([$p1, $p2]);
$pool->setOnSuccess(function (Process $process, float $duration) {
    printf('Process Complete: [pid: %d, cmd: %s]', $process->getPid(), $process->getCommandLine());
    print($process->getOutput()); // gets stdout
    print($process->getErrorOutput()); // gets stderr
});
$pool->setOnFailure(function (Process $process, float $duration) {
    printf('Process Failed: [pid: %d, cmd: %s, code: %d]', $process->getPid(), $process->getCommandLine(), $process->getExitCode());
    print($process->getOutput()); // gets stdout
    print($process->getErrorOutput()); // gets stderr
});

or something like that. You can do what you want to with the output at this point. Like add the pid to each line of the output... or whatever

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants