定制 netlogix/supervisor 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

netlogix/supervisor

Composer 安装命令:

composer require netlogix/supervisor

包简介

Create supervisor program groups and programs via CLI.

README 文档

README

This package creates supervisor configuration files via flow CLI.

Configuration files are named "group-something.conf" when they contain a supervisor group configuration or "program-something.conf" when they contain a supervisor program configuration. Both are created at Configuration/Supervisor within your application.

Setup:

Supervisor allows to "include" other files and even allows for globbing.

# cat /etc/supervisor/supervisord.conf
[include]
files=/etc/supervisor/conf.d/*.conf /var/www/*/Configuration/Supervisor/group.conf /var/www/*/Configuration/Supervisor/program*.conf

Creating supervisor files dynamically is intended to be a compile time step, preferably on deployment.

Available configuration options:

Program settings get passed to the supervisor configuration file without validation, so every current and future configuration option is available.

See: http://supervisord.org/configuration.html#program-x-section-settings

Available flow commands:

./flow supervisor:create          Creates supervisor configuration
./flow supervisor:startgroups     Starts all programs of configured groups
./flow supervisor:stopgroups      Stops all programs of configured groups
./flow supervisor:updategroups    Reloads config and starts/stops programs accordingly

Create supervisor settings via YAML:

Although supervisor programs can be created entirely via yaml, those are basically static because the yaml configuration format does not provide iteration or dynamic construction mechanisms.

Netlogix:
    Supervisor:

        programs:

            changes-command-controller-polling-action:

                command: './flow changes:poll ; sleep 5'
                name: 'this-is-a-program'
                environment: "FLOW_CONTEXT='%env:FLOW_CONTEXT%'"
                directory: "%FLOW_PATH_ROOT%"

For more details: See Configuration/Settings.yaml.example

Create supervisor settings via PHP:

There is a Provider interface which allows other packages to hook an and create Supervisor Program settings in a completely programmatic manner.

class Provider implements \Netlogix\Supervisor\Provider
{
    /**
     * @return array<\Netlogix\Supervisor\Model\Program>
     */
    public function getPrograms(): array
    {
        $name = 'this-is-a-program';
        $groupName = 'default';
        $command = './flow changes:poll ; sleep 5';
        $programSettings = [
            'environment' =>  \sprintf(
                "FLOW_CONTEXT='%s'",
                Bootstrap::getEnvironmentConfigurationSetting('FLOW_CONTEXT') ?: 'Development'
            ),
            'directory' => \FLOW_PATH_ROOT
        ];
        return [
            new \Netlogix\Supervisor\Model\Program(
                $name,
                $groupName,
                $command,
                $programSettings
            );
        ];
    }
}

Configure group settings:

Groups are created on demand as soon as a program assigns itself to the group. This means groups don't need to be configured beforehand or even at all.

If no further configuration is presented, the supervisor group name is generated from the "groupName" configuration option of a program.

Groups can override their names. This menas several programs can e.g. refer to the same group "default" but the group can be renamed if different applications share a common supervisor daemon.

This setting also provides a priority setting.

Netlogix:
  Supervisor:

    groups:
      default:
        name: "%FLOW_PATH_ROOT%"
        priority: 200

Renamed identifiers:

Both, group names and program names need to be cleaned to comply with supervisors naming scheme. This is done automatically, so even if the group name is configured as %FLOW_PATH_ROOT% it will be transformed to var-www-document-root.

netlogix/supervisor 适用场景与选型建议

netlogix/supervisor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 306.74k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 11 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 netlogix/supervisor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 netlogix/supervisor 我们能提供哪些服务?
定制开发 / 二次开发

基于 netlogix/supervisor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 306.74k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 20
  • 依赖项目数: 1
  • 推荐数: 1

GitHub 信息

  • Stars: 0
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-11-19