Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
Tentative Fix for #25
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e committed Aug 21, 2013
1 parent 7f581a7 commit 1d6f402
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Lib/CakeResqueBootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@
new ShellDispatcher($argv);
App::uses('Shell', 'Console');

App::uses('Resque_Job_Creator', 'CakeResque.Lib');
require_once 'Resque_Job_Creator.php';

This comment has been minimized.

Copy link
@bar

bar Nov 6, 2013

Contributor

Did this change finally solve something?

This comment has been minimized.

Copy link
@wa0x6e

wa0x6e Nov 6, 2013

Author Owner

No. But we can leave it as is

This comment has been minimized.

Copy link
@bar

bar Nov 6, 2013

Contributor

If you use your own bootstrap, you have to change that line always. But it you let Cake decide where it is (using App), it is just a copy/paste.

This comment has been minimized.

Copy link
@wa0x6e

wa0x6e Nov 6, 2013

Author Owner

The fix introduced later should make sure that App is always your app (app/), and not default to lib/Cake anymore.

This comment has been minimized.

Copy link
@bar

bar Nov 6, 2013

Contributor

Yes, I saw you fixed it using getenv('CAKE').

Cake will always give you the correct location for the Resque_Job_Creator file by means of App::uses() because ShellDispatcher() loads App class before that.

This comment has been minimized.

Copy link
@bar

bar Nov 6, 2013

Contributor

I mean, below the new ShellDispatcher($argv); line, it is always better to stick with Cake.

This comment has been minimized.

Copy link
@wa0x6e

wa0x6e Nov 6, 2013

Author Owner

You proposing to revert back to App::uses ?

This comment has been minimized.

Copy link
@bar

bar Nov 6, 2013

Contributor

Yes, just that very line. It makes it easier for people to clone CakeResqueBootstrap.php.

This comment has been minimized.

Copy link
@wa0x6e

wa0x6e Nov 6, 2013

Author Owner

I see, It makes sense if you're cloning it.

Just for curiosity, why would anyone need to clone it ?

This comment has been minimized.

Copy link
@bar

bar Nov 6, 2013

Contributor

For example, if your application behaves differently depending on a special variable (set in the web server for example), then you need the worker to behave differently using custom vars too.

So you first set that special var inside CakeResque.Env so that it ends in the cli as an env variable. Later it needs to be read before actually being dispatched (like if the cake shell where the web server).

That leads you to having multiple workers per app, and at least 1 worker per app.

10 changes: 3 additions & 7 deletions Lib/Resque_Job_Creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@
*/
class Resque_Job_Creator {

/**
* Application Root Folder path
* @var String
*/
public static $rootFolder = APP;

/**
* Create and return a job instance
*
Expand All @@ -35,7 +29,9 @@ class Resque_Job_Creator {
*/
public static function createJob($className, $args) {
list($plugin, $model) = pluginSplit($className);
$classpath = self::$rootFolder . (empty($plugin) ? '' : 'Plugin' . DS . $plugin . DS) . 'Console' . DS . 'Command' . DS . $model . '.php';
$appRoot = dirname(dirname(dirname(__DIR__)));
$classpath = $appRoot . DS . (empty($plugin) ? '' : 'Plugin' . DS . $plugin . DS) . 'Console' . DS . 'Command' . DS . $model . '.php';

if (file_exists($classpath)) {
require_once $classpath;
} else {
Expand Down

0 comments on commit 1d6f402

Please sign in to comment.