[英]Envoyer Deployment with custom artisan command fails
I have a problem deploying my project with envoyer which executes an artisan-command I created. 我在使用envoyer部署我的项目时遇到问题,该执行器执行我创建的工匠命令。
The command gets all my users, performs another artisan command ( $this->call('command')
) and performs it actions by iterating through all the users. 该命令获取我的所有用户,执行另一个工匠命令(
$this->call('command')
)并通过遍历所有用户来执行它的操作。
The problems lies here: 问题在于:
foreach($usernames as $username) {
shell_exec('php ' . base_path('artisan') . ' command ' . $username . ' > /dev/null 2>/dev/null &');
}
This command starts a script in the background. 此命令在后台启动脚本。 Its getting executed without any problems manually and doesn't end in a timeout (takes about 1s~ to execute) but in envoyer it wont stop running in the deploying step and fails in a timeout altough it executes flawless.
它在没有任何问题的情况下手动执行并且不会在超时结束(执行大约需要1秒),但在envoyer中它不会在部署步骤中停止运行并在超时时失败,尽管它执行完美无瑕。
Additional informations: 其他信息:
For the reason why i'm running the script in the background: 因为我在后台运行脚本的原因:
The script im starting opens a socket which he will listen 24/7 until the user cancel it manually. 我开始的脚本打开一个套接字,他将全天候收听,直到用户手动取消它。
I've just created a smaller example to make sure it's all working fine: 我刚刚创建了一个较小的示例,以确保它一切正常:
File forever.php
will keep an infinite loop printing something every 5 seconds: 文件
forever.php
将每隔5秒保持一次无限循环打印:
<?php
while (true) {
echo "I am still in the loop $argv[1]\n";
sleep(5);
}
File script.php
will call multiple instances of forever.php
and detach from the parent process (same as what you did): 文件
script.php
将调用的多个实例forever.php
从父进程(一样的,你做了什么)分离:
<?php
for ($i = 0; $i < 5; $i++) {
shell_exec("php forever.php $i > /dev/null 2>/dev/null &");
}
When executing php script.php
, obviously there's 5 instances of forever.php
running. 执行
php script.php
,很明显运行了forever.php
的5个实例。 So your code seems fine (the part you've shown). 所以你的代码似乎很好(你展示的部分)。
The only things I can think of in your case are: 在你的案例中我唯一能想到的是:
Hope it helps, if you need more help please provide some more information. 希望它有所帮助,如果您需要更多帮助,请提供更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.