All Projects β†’ cocur β†’ Background Process

cocur / Background Process

Licence: mit
Start processes in the background that continue running when the PHP process exists.

Labels

Projects that are alternatives of or similar to Background Process

jobflow
runs stuff in parallel (like GNU parallel, but much faster and memory-efficient)
Stars: ✭ 67 (-76.41%)
Mutual labels:  process
fake-sandbox
πŸ‘β€πŸ—¨ This script will simulate fake processes of analysis sandbox/VM software that some malware will try to avoid.
Stars: ✭ 110 (-61.27%)
Mutual labels:  process
core d.js
Offload your heavy lifting to a daemon. Extracted from eslint_d.
Stars: ✭ 21 (-92.61%)
Mutual labels:  process
proc-maps
Read virtual memory maps from another process
Stars: ✭ 25 (-91.2%)
Mutual labels:  process
tgrid
TypeScript Grid Computing Framework supporting RFC (Remote Function Call)
Stars: ✭ 83 (-70.77%)
Mutual labels:  process
Process
Creation of Dynamic Dedicated WebWorkers, definition of dependencies, promise support.
Stars: ✭ 13 (-95.42%)
Mutual labels:  process
unshare
The low-level linux containers creation library for rust
Stars: ✭ 99 (-65.14%)
Mutual labels:  process
graceful
Gracefully exit server (Koa), database (Mongo/Mongoose), Redis clients, and job scheduler (Redis/Bull)
Stars: ✭ 37 (-86.97%)
Mutual labels:  process
PRUNE
Logs key Windows process performance metrics. #nsacyber
Stars: ✭ 56 (-80.28%)
Mutual labels:  process
my curd
袅轻量 εΏ«ι€ŸεΌ€ε‘θ„šζ‰‹ζžΆγ€ζ΅η¨‹εΉ³ε°γ€‚
Stars: ✭ 38 (-86.62%)
Mutual labels:  process
Post-Mortems-Template
An Incident Management Process / Post Mortem Template
Stars: ✭ 23 (-91.9%)
Mutual labels:  process
DLL-Injector
Inject and detour DLLs and program functions both managed and unmanaged in other programs, written (almost) purely in C#. [Not maintained].
Stars: ✭ 29 (-89.79%)
Mutual labels:  process
ExecutionMaster
Windows utility for intercepting process creation and assigning standard actions to program startup
Stars: ✭ 54 (-80.99%)
Mutual labels:  process
prox
A Scala library for working with system processes
Stars: ✭ 93 (-67.25%)
Mutual labels:  process
camunda-bpm-data
Beautiful process data handling for Camunda BPM.
Stars: ✭ 24 (-91.55%)
Mutual labels:  process
jellex
TUI to filter JSON and JSON Lines data with Python syntax
Stars: ✭ 41 (-85.56%)
Mutual labels:  process
codebase
The jBPT code library is a compendium of technologies that support research on design, execution, and evaluation of business processes. The library offers a broad range of basis analysis and utility functionality and, due to its open publishing model, can easily be extended.
Stars: ✭ 26 (-90.85%)
Mutual labels:  process
Tiny Process Library
A small platform independent library making it simple to create and stop new processes in C++, as well as writing to stdin and reading from stdout and stderr of a new process
Stars: ✭ 276 (-2.82%)
Mutual labels:  process
pmap
Process Map Visualization of event analysis in R
Stars: ✭ 19 (-93.31%)
Mutual labels:  process
async-pidfd
Rust crate to use process file descriptors (pidfd) for Linux
Stars: ✭ 42 (-85.21%)
Mutual labels:  process

cocur/background-process

Start processes in the background that continue running when the PHP process exists.

Latest Stable Version Build Status Windows Build status Code Coverage

Installation

You can install Cocur\BackgroundProcess using Composer:

$ composer require cocur/background-process

Usage

The following example will execute the command sleep 5 in the background. Thus, if you run the following script either in the browser or in the command line it will finish executing instantly.

use Cocur\BackgroundProcess\BackgroundProcess;

$process = new BackgroundProcess('sleep 5');
$process->run();

You can retrieve the process ID (PID) of the process and check if it's running:

use Cocur\BackgroundProcess\BackgroundProcess;

$process = new BackgroundProcess('sleep 5');
$process->run();

echo sprintf('Crunching numbers in process %d', $process->getPid());
while ($process->isRunning()) {
    echo '.';
    sleep(1);
}
echo "\nDone.\n";

If the process runs you can stop it:

// ...
if ($process->isRunning()) {
    $process->stop();
}

Please note: If the parent process continues to run while the child process(es) run(s) in the background you should use a more robust solution, for example, the Symfony Process component.

Windows Support

Since Version 0.5 Cocur\BackgroundProcess has basic support for Windows included. However, support is very limited at this time. You can run processes in the background, but it is not possible to direct the output into a file and you can not retrieve the process ID (PID), check if a process is running and stop a running process.

In practice, the following methods will throw an exception if called on a Windows system:

  • Cocur\BackgroundProcess\BackgroundProcess::getPid()
  • Cocur\BackgroundProcess\BackgroundProcess::isRunning()
  • Cocur\BackgroundProcess\BackgroundProcess::stop()

Create with existing PID

If you have a long running process and store its PID in the database you might want to check at a later point (when you don't have the BackgroundProcess object anymore) whether the process is still running and stop the process.

use Cocur\BackgroundProcess\BackgroundProcess;

$process = BackgroundProcess::createFromPID($pid);
$process->isRunning(); // -> true
$process->stop();      // -> true

Change Log

Version 0.7 (11 February 2017)

Version 0.6 (10 July 2016)

  • #17 Add ability to append to file on Unix/Linux-based systems (by bpolaszek)

Version 0.5 (24 October 2015)

  • Added basic support for Windows

Version 0.4 (2 April 2014)

  • Moved repository to Cocur organization
  • Changed namespace to Cocur
  • PSR-4 compatible namespace
  • #3 Added BackgroundProcess::stop() (by florianeckerstorfer)

Version 0.3 (15 November 2013)

  • Changed namespace to Braincrafted

Author

Florian Eckerstorfer

License

The MIT license applies to cocur/background-process. For the full copyright and license information, please view the LICENSE file distributed with this source code.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].