Process::Launcher - Execute Process objects from the command line
# Create from passed params and run perl -MProcess::Launcher -e run MyProcessClass param value # Create from STDIN params and run perl -MProcess::Launcher -e run3 MyProcessClass # Thaw via Storable from STDIN, and freeze back after to STDOUT perl -MProcess::Launcher -e storable MyProcessClass # Requires Process::YAML to be installed: # Thaw via YAML::Syck from STDIN, and freeze back after to STDOUT perl -MProcess::Launcher -e yaml MyProcessClass
The Process::Launcher module provides a mechanism for launching and running a Process-compatible object from the command line, and returning the results.
Process::Launcher
Most use cases involve isolation. By having a Process object run inside its own interpreter, it is then free do things such as loading in vast amounts of data and modules without bloating out the main process.
Process
It could provide a novel way of giving Out Of Memory (OOM) protection to your Perl process, because when the operating system's OOM-killer takes out the large (or runaway) process, the main program is left intact.
It provides a way to run some piece of code in a different Perl environment than your own. This could mean a different Perl version, or running something with tainting on without needing the main process to have tainting.
All functions are imported into the callers by default.
The run function creates an object based on the arguments passed to the program on the command line.
run
The first param is take as the Process class and loaded, and the rest of the params are passed directly to the constructor.
Note that this does mean you can't pass anything more complex than simple string pairs. If you need something more complex, try the storable function below.
storable
Prints one line of output at the end of the process run.
# Prints the following if the process completed correctly OK # Prints the following if the process does not complete FAIL - reason
The run3 function is similar to the run function but assumes you are launching the process via something that makes it easy to pass in params via STDIN, such as IPC::Run3 (recommended)
run3
STDIN
It takes a single param of the Process class.
It then readsa series of key-value pairs from STDIN in the form
param1=value param2=value
At the end of the input, the key/value pairs are passed to the constructor, and from there the function behaves identically to run above, including output.
The serialized function is more robust and thorough again.
serialized
It takes the name of a Process::Serializable subclass as its parameter, reads data in from STDIN, then calls the deserialize method for the class to get the Process object.
deserialize
This object has prepare and then run called on it.
prepare
The same OK or FAIL line will be written as above, but after that first line, the completed object will be frozen back out via serialize and written to STDOUT as well.
OK
FAIL
serialize
STDOUT
The intent is that you create your object of the Process::Serializable subcless in your main interpreter thread, then hand it off to another Perl instance for execution, and then optionally return it to handle the results.
Process::Serializable
Bugs should be reported via the CPAN bug tracker at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Process
For other issues, contact the author.
Adam Kennedy <adamk@cpan.org>
http://ali.as/
Copyright 2006 - 2011 Adam Kennedy.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
To install Process, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Process
CPAN shell
perl -MCPAN -e shell install Process
For more information on module installation, please visit the detailed CPAN module installation guide.