Skip to content

Commit

Permalink
Merge pull request #6 from wcombs/master
Browse files Browse the repository at this point in the history
added errorcode capturing and extended job status expire time
  • Loading branch information
wcombs committed Aug 21, 2015
2 parents 908bfb1 + 03ae695 commit da4eeec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/Resque/Failure/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function __construct($payload, $exception, $worker, $queue)
$data->worker = (string)$worker;
$data->queue = $queue;
$data = json_encode($data);
Resque::redis()->set('job:' . $payload["id"] . ':status:errorcode', $exception->getCode());
Resque::redis()->rpush('failed', $data);
}
}
Expand Down
5 changes: 3 additions & 2 deletions lib/Resque/Job/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Resque_Job_Status
const STATUS_RUNNING = 2;
const STATUS_FAILED = 3;
const STATUS_COMPLETE = 4;
const STATUS_EXPIRE_SECS = 604800;
const STATUS_EXPIRE_SECS = 2419200;

/**
* @var string The ID of the job this status class refers back to.
Expand Down Expand Up @@ -106,13 +106,14 @@ public function update($status, $data)
Resque::redis()->set((string)$this . ':timestarted', $now);
}

// Expire the status for completed jobs after 24 hours
// Expire the status for completed jobs after 30 days
if(in_array($status, self::$completeStatuses)) {
Resque::redis()->set((string)$this . ':timecompleted', $now);
Resque::redis()->expire((string)$this, self::STATUS_EXPIRE_SECS);
Resque::redis()->expire((string)$this . ':timequeued', self::STATUS_EXPIRE_SECS);
Resque::redis()->expire((string)$this . ':timestarted', self::STATUS_EXPIRE_SECS);
Resque::redis()->expire((string)$this . ':timecompleted', self::STATUS_EXPIRE_SECS);
Resque::redis()->expire((string)$this . ':errorcode', self::STATUS_EXPIRE_SECS);
}
}

Expand Down

0 comments on commit da4eeec

Please sign in to comment.