Skip to content

Instantly share code, notes, and snippets.

View gustavonecore's full-sized avatar
🛠️
I can kill two stones with one bird

Gustavo Delgado gustavonecore

🛠️
I can kill two stones with one bird
View GitHub Profile
@gustavonecore
gustavonecore / job-server.sh
Created October 23, 2017 03:52
Codeigniter job server - bin bash job consumer
/usr/local/bin/php /path/to/your/ci/root/folder/index.php jobs listen
@gustavonecore
gustavonecore / Schedules.php
Created October 23, 2017 03:48
Codeigniter job-server - Schedules controller example
<?php
foreach ($receivers as $receiver)
{
$this->model->create('jobs', [
'name' => 'sendEmail',
'payload' => json_encode([
'subject' => 'My beautiful subject',
'type' => 'html',
'message' => 'This is an email!',
@gustavonecore
gustavonecore / job_scheme.sql
Last active October 25, 2017 15:56
Codeigniter job table
CREATE TABLE `jobs` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) NOT NULL,
`payload` TEXT NULL COMMENT 'JSON payload',
`response` TEXT NULL,
`status` ENUM('running', 'queued', 'done') NOT NULL DEFAULT 'queued',
`run_time` DOUBLE NULL,
`created_dt` DATETIME NOT NULL,
PRIMARY KEY (`id`));
@gustavonecore
gustavonecore / jobs.php
Last active October 1, 2021 13:05
Codeigniter job server dispatcher
<?php
/**
* Class to handle job execution
*/
class Jobs extends Onecore_Controller
{
const STATUS_DONE = 'done';
const STATUS_QUEUED = 'queued';
const STATUS_RUNNING = 'running';