setono/deployer-supervisor

处理部署中的supervisor配置

v1.2.0 2023-04-19 06:09 UTC

This package is auto-updated.

Last update: 2024-09-15 18:31:00 UTC


README

Latest Version Software License Build Status

安装

composer require setono/deployer-supervisor

使用

在你的 deploy.php 文件中引入食谱

<?php

namespace Deployer;

require_once 'recipe/setono_supervisor.php';

// ...

这将自动钩入Deployer的默认流程。

然后在 etc/supervisor (在你的仓库中) 创建一个配置文件,如下所示

;etc/supervisor/service1.conf
[program:service1]
command={{bin/php}} {{bin/console}} messenger:consume async
user={{http_user}}
autostart=true
autorestart=true

注意 你可以在配置文件中使用Deployer的参数!

在(重新)启动服务前添加延迟

;etc/supervisor/service1.conf
[program:service1]
command=bash -c "sleep 10 && exec {{bin/php}} {{bin/console}} messenger:consume async"
user={{http_user}}
autostart=true
autorestart=true
startsecs=15

在这个示例中,我们在运行实际命令前插入10秒的延迟,并将 startsecs 改为15(比延迟多5秒),这样supervisor就不会在15秒后计算进程为运行。