yii2-queue icon indicating copy to clipboard operation
yii2-queue copied to clipboard

Why are environment variables not passed to the created process?!

Open mymagikbox opened this issue 2 years ago • 5 comments

Why are environment variables not passed to the created process?!

https://github.com/yiisoft/yii2-queue/blob/726a4fd55aecb4ccefd4957b42d28d35c3ea653e/src/cli/Command.php#L185

I use the vlucas/phpdotenv library and my entire database connection configuration is in environment variables. Why can’t you pass local variables into the running process - this will solve the problem!

$env = isset($_ENV) ? $_ENV : null;

$process = new Process($cmd, null, $env, $message, $ttr);

mymagikbox avatar Sep 21 '23 00:09 mymagikbox

Will it solve what problem? Can you write more about the problem?

s1lver avatar Sep 22 '23 14:09 s1lver

In my case this will solve the problem. When php yii queue/run is started, environment variables are initialized. Next, the tasks themselves are executed individually, in debaug i see yii queue/exec 18 300 (some args...) , but for some reason without environment variables. As I understand it, they are running in an individual process, why not put environment variables into it?! code above.

mymagikbox avatar Sep 22 '23 20:09 mymagikbox

I think it makes sense to pass environment variables to sub-process.

samdark avatar Oct 19 '23 16:10 samdark

强烈建议将环境变量传递给子进程!

over-star avatar Mar 14 '24 06:03 over-star

It is strongly recommended to pass environment variables to child processes!

over-star avatar Mar 14 '24 06:03 over-star