phpgt / daemon Goto Github PK
View Code? Open in Web Editor NEWBackground process execution.
Home Page: https://www.php.gt/daemon
License: MIT License
Background process execution.
Home Page: https://www.php.gt/daemon
License: MIT License
Running a pool of three or four processes makes my laptop fans go fast. Probably something simple.
When constructing a new Process, provide optional cwd to work from.
Here is the changelog for 7.4: https://github.com/php/php-src/blob/PHP-7.4/UPGRADING#L323
A problem that has been encountered within this repository is when executing sub-scripts. If a new script is executed, its PID has to be held reference to so that it can be manually killed if the script dies. If the program crashes, it's possible to leave zombie processes running.
Starting a process using the array syntax removes the sub-shell execution, allowing PHP to properly maintain its child processes.
Dependabot needs to be tamed, as per PhpGt/WebEngine#568
Since the latest WIP update, the setting of environment variables is losing some already set variables in the environment.
For example, running gt serve
now works with the additional threads, but there is an issue when running gt build
as it no longer has commands like node
in the PATH, even though the outer calling shell does.
here is the script you mentioned you would like help on last night:
<?php
$pipeDetails = [
"out" => ["fh" => STDOUT],
"err" => ["fh" => STDERR],
];
foreach($pipeDetails as $pipeName => $details) {
$socket = stream_socket_server(
"tcp://127.0.0.1:0",
$errno,
$errstr
);
if(!$socket) {
die("Error: $errstr ($errno)" . PHP_EOL);
}
$addr = stream_socket_get_name($socket, false);
$pipeDetails[$pipeName]["socket"] = $socket;
$pipeDetails[$pipeName]["addr"] = $addr;
socket_set_blocking($socket, false);
}
$outAddr = $pipeDetails["out"]["addr"];
$errAddr = $pipeDetails["err"]["addr"];
$cmd = "php counter.php";
$process = proc_open(
"( $cmd 2>&3 | php client.php out $outAddr; ) 3>&1 1>&2 | ( php client.php err $errAddr )",
[],
$pipes
);
if(!$process) {
die("Process failed to start." . PHP_EOL);
}
$pipeDetails["out"]["stream"] = stream_socket_accept($pipeDetails["out"]["socket"], 1);
$pipeDetails["err"]["stream"] = stream_socket_accept($pipeDetails["err"]["socket"], 1);
do {
foreach($pipeDetails as $pipeName => $detail) {
$stream = $pipeDetails[$pipeName]["stream"];
if(!$stream) {
continue;
}
$msg = fread($stream, 256);
fwrite($detail["fh"], $msg);
usleep(100000);
}
$status = proc_get_status($process);
}
while($status["running"]);
Add a callback function to execute when the process completes.
Currently there are two boolean flags on the Process::exec
function. These should be moved to setters (setBlocking, setExec, for example). This will allow easier refactoring, especially for #9
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.