如何暂停Laravel Horizo​​n的主管

发布于 2025-02-06 10:24:50 字数 1465 浏览 3 评论 0原文

我在地平线上有多个主管,他们正常工作,问题是我想通过自己的Web界面与他们进行交互,并且通过交互,我的意思是puse 他们和继续(解开它们)。

为此,我希望不使用系统(在Artisan Horizo​​n:暂停supervisor它发送posix_kill($ sustistor-> pid,12))。

我尝试通过这样做来实例化主管:

class HorizonManager
{
    private SupervisorRepository       $supervisors;
    private MasterSupervisorRepository $masters;
    private WorkloadRepository         $workload;
    private RedisJobRepository         $jobRepository;
    private QueueManager               $queueManager;

    public function __construct(MasterSupervisorRepository $masters, SupervisorRepository $supervisors, WorkloadRepository $workload, RedisJobRepository $jobRepository, QueueManager $manager)
    {
        $this->masters = $masters;
        $this->supervisors = $supervisors;
        $this->workload = $workload;
        $this->jobRepository = $jobRepository;
        $this->queueManager = $manager;

    }

    public function pauseSupervisor(string $supervisorName){
        $supervisor = $this->supervisors->find($supervisorName);
        $supervisorOpt = new SupervisorOptions(...$supervisor->options);
        $sup = new Supervisor($supervisorOpt);
        $sup->pause();
        $sup->persist();
        return $this->supervisors->find($supervisorName);
    }
}

在功能的返回中,我暂停了主管,但并没有真正暂停(即使我坚持实例化主管,它仍然作为一个过程运行)

I have multiple supervisor in horizon, and they work normally, the problem is that I want to interact with them by my own web interface, and by interacting I mean pause them and continue (unpause them).

To do that I want to be able as much as possible, without using system (in artisan horizon:pause-supervisor it sends posix_kill($supervisor->pid, 12)).

I tried to instantiate the supervisor by doing this :

class HorizonManager
{
    private SupervisorRepository       $supervisors;
    private MasterSupervisorRepository $masters;
    private WorkloadRepository         $workload;
    private RedisJobRepository         $jobRepository;
    private QueueManager               $queueManager;

    public function __construct(MasterSupervisorRepository $masters, SupervisorRepository $supervisors, WorkloadRepository $workload, RedisJobRepository $jobRepository, QueueManager $manager)
    {
        $this->masters = $masters;
        $this->supervisors = $supervisors;
        $this->workload = $workload;
        $this->jobRepository = $jobRepository;
        $this->queueManager = $manager;

    }

    public function pauseSupervisor(string $supervisorName){
        $supervisor = $this->supervisors->find($supervisorName);
        $supervisorOpt = new SupervisorOptions(...$supervisor->options);
        $sup = new Supervisor($supervisorOpt);
        $sup->pause();
        $sup->persist();
        return $this->supervisors->find($supervisorName);
    }
}

In the return from the function, I have the supervisor paused, but it's not really paused (even If I persist the instantiate supervisor it's still running as a process)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薯片软お妹 2025-02-13 10:24:50

对于那些有兴趣的人,我无法通过实现它来进行操作,因此我使用工匠呼叫发送命令:

define('SIGUSR2', 12);
Artisan::call('horizon:pause-supervisor', ['name'=>$supervisorName]);
$supervisor = $this->supervisors->find($supervisorName);
$supervisor->status = 'paused';

For those interested I failed doing it by instanciating it so instead I send the command using artisan call :

define('SIGUSR2', 12);
Artisan::call('horizon:pause-supervisor', ['name'=>$supervisorName]);
$supervisor = $this->supervisors->find($supervisorName);
$supervisor->status = 'paused';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文