Why are environment variables not passed to the created process?!
mymagikbox opened this issue · 5 comments
Why are environment variables not passed to the created process?!
yii2-queue/src/cli/Command.php
Line 185 in 726a4fd
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);
Will it solve what problem? Can you write more about the problem?
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.
I think it makes sense to pass environment variables to sub-process.
强烈建议将环境变量传递给子进程!
It is strongly recommended to pass environment variables to child processes!