Dan Bough
Dan Bough

Reputation: 509

Perl command executor with IPC::Run

I need to write a "command executor" that does the following:

  1. Gathers commands from a database.
  2. Spawns $LIMIT amount of commands (that will run asynchronously).
  3. When 1 command finishes another one can start (as long as the command $LIMIT isn't reached).
  4. The command should not be spawned by a child of the parent (I don't want to run a child process + the command process).
  5. Records results to database & log file (exit state, stdout & stderr).
  6. Is written in Perl ( or PHP ).

I've tested IPC::Run. I've only been able to get it to run commands in chunks (X at a a time). I'd have to wait for those X to complete, then run another chunk. I could be doing something wrong though - the reference page for it is tough to follow. Will this do what I need?

I've also found the following which looks promising (How to write parallel programs in Perl?). Will this do what I need?

Upvotes: 1

Views: 396

Answers (1)

mob
mob

Reputation: 118605

Conditions 2 and 3 are called throttling, and this feature is provided by modules such as Parallel::ForkManager and Forks::Super (I am the author of Forks::Super).

Upvotes: 1

Related Questions