tigron / skeleton-transaction
骨架的后台任务
v4.0.1
2023-10-06 13:50 UTC
Requires
- tigron/skeleton-core: >=4
- tigron/skeleton-database: >=0.2.2
- tigron/skeleton-object: >=0.1.18
Requires (Dev)
- tigron/skeleton-database: dev-master
- tigron/skeleton-object: dev-master
- dev-master
- 4.x-dev
- v4.0.1
- v4.0.0
- 1.x-dev
- v1.1.7
- v1.1.6
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- v0.5.2
- v0.5.1
- v0.5.0
- v0.4.4
- v0.4.3
- v0.4.2
- v0.4.1
- v0.4.0
- v0.3.13
- v0.3.12
- v0.3.11
- v0.3.10
- v0.3.9
- v0.3.8
- v0.3.7
- v0.3.6
- v0.3.5
- v0.3.4
- v0.3.3
- v0.3.2
- v0.3.1
- v0.3.0
- v0.2.8
- v0.2.7
- v0.2.6
- v0.2.5
- v0.2.4
- v0.2.3
- v0.2.2
- v0.2.1
- v0.2.0
- v0.1.2
- v0.1.1
- v0.1.0
- v0.0.1
This package is auto-updated.
Last update: 2024-09-06 16:10:04 UTC
README
描述
骨架的事务。事务用于执行后台任务。
安装
通过composer安装
composer require tigron/skeleton-transaction
如何设置
运行初始迁移
创建事务
所有事务都应扩展自 \Skeleton\Transaction\Transaction 并实现 run() 方法
<?php
/**
* Transaction_Test
*
* @author Christophe Gosiau <christophe@tigron.be>
*/
class Transaction_Test extends \Skeleton\Transaction\Transaction {
/**
* Run
*
* @access public
*/
public function run() {
// Do your thing
$data = $this->get_data();
}
}
安排事务
$transaction = new Transaction_Email_Order_Canceled();
$data = [ 'some_data' => 'some_value ];
$transaction->data = $data;
$transaction->schedule();
管理守护进程
使用骨架二进制文件启动事务守护进程
skeleton transaction:daemon start
停止事务守护进程
skeleton transaction:daemon stop
获取守护进程状态
skeleton transaction:daemon status
与事务交互
获取所有已安排事务的列表
skeleton transaction:list
运行事务
skeleton transaction:run <transaction_id>
显示事务日志
skeleton transaction:log <transaction_id_or_classname>
使用Nagios监控守护进程
Skeleton Transaction Daemon可以通过其状态文件进行监控。状态文件每5秒更新一次,可以通过配置进行配置。
\Skeleton\Transaction\Config::$monitor_file = '/tmp/skeleton-transaction.status';
要使用Nagios监控守护进程,提供了一个 \Skeleton\Core\Web\Module,该模块将读取状态文件并返回适当的响应。
要启用Nagios监控,请确保在应用程序中创建一个处理监控请求的模块
<?php
/**
* Module monitor
*
* @author Christophe Gosiau <christophe@tigron.be>
*/
class Web_Module_Monitor extends \Skeleton\Transaction\Web\Module\Monitor {
}
可选地,可以配置身份验证头
\Skeleton\Transaction\Config::$monitor_authentication = 'YOUR_SECRET_STRING';
Nagios配置
在Nagios中,您应该配置一个 command
来调用服务。我们将使用内置的 check_http
命令作为起点
define command {
command_name check_skeleton_http
command_line /usr/lib/nagios/plugins/check_http -H $ARG1$ -u $ARG2$ -k 'X-Authentication: $ARG3$'
}
您的服务定义可能如下所示
define service {
use generic-service
host_name hostname.example.com
service_description SKELETON
check_command check_skeleton_http!app.hostname.example.com!/monitor!AuThEnTiCaTiOnStRiNg
}