Giter Site home page Giter Site logo

daemon's People

Contributors

g105b avatar sayyassine9 avatar

Watchers

 avatar  avatar  avatar

daemon's Issues

Environment variables are overwriting current environment

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.

Support for PHP 7.4 shell-less commands

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.

CPU usage

Running a pool of three or four processes makes my laptop fans go fast. Probably something simple.

windows usage

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"]);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.