tigron / skeleton-transaction
Background tasks for skeleton
Installs: 14 836
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 6
Forks: 0
Open Issues: 2
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
- dev-feature/quality
This package is auto-updated.
Last update: 2025-01-03 15:04:49 UTC
README
Description
Transactions for Skeleton. Transactions are used to perform background tasks.
Installation
Installation via composer:
composer require tigron/skeleton-transaction
Howto setup
Run the initial migrations
Create transactions
Transactions should all extend from \Skeleton\Transaction\Transaction and should implement the run() method:
<?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();
}
}
Schedule your transaction
$transaction = new Transaction_Email_Order_Canceled();
$data = [ 'some_data' => 'some_value ];
$transaction->data = $data;
$transaction->schedule();
Manage the daemon
Start the transaction daemon with the skeleton binary:
skeleton transaction:daemon start
Stop the transaction daemon
skeleton transaction:daemon stop
Get the status of the daemon
skeleton transaction:daemon status
Interact with transactions
Get a list of all scheduled transactions
skeleton transaction:list
Run a transaction
skeleton transaction:run <transaction_id>
Show the log of a transaction
skeleton transaction:log <transaction_id_or_classname>
Monitor the daemon with Nagios
Skeleton Transaction Daemon can be monitored via its status file. The status file is updated every 5 seconds and can be configured via Config:
\Skeleton\Transaction\Config::$monitor_file = '/tmp/skeleton-transaction.status';
To monitor the daemon via Nagios, a \Skeleton\Core\Web\Module is provided which will read the status file and return an appropiate response.
To enable Nagios monitoring, make sure to create a module in your application that will handle the monitoring request:
<?php
/**
* Module monitor
*
* @author Christophe Gosiau <christophe@tigron.be>
*/
class Web_Module_Monitor extends \Skeleton\Transaction\Web\Module\Monitor {
}
Optionally, an authentication header can be configured:
\Skeleton\Transaction\Config::$monitor_authentication = 'YOUR_SECRET_STRING';
Nagios configuration
In Nagios, you should configure a command
to call the service. We will use the
built-in check_http
command as a starting point:
define command {
command_name check_skeleton_http
command_line /usr/lib/nagios/plugins/check_http -H $ARG1$ -u $ARG2$ -k 'X-Authentication: $ARG3$'
}
Your service definition could then look like this:
define service {
use generic-service
host_name hostname.example.com
service_description SKELETON
check_command check_skeleton_http!app.hostname.example.com!/monitor!AuThEnTiCaTiOnStRiNg
}