Open johannesx75 opened 8 years ago
From what I can tell the gearman server config is currently hard coded to be localhost:4730 in multiple places
On the job creation side of things, these are just the default settings; to change that, you can specify the alternatives via
Injector:
GearmanService:
host: myhostname
port: 1234
As for running jobs, for your specific use-case, I'm not sure that either of the example *_runner.php
scripts will do exactly what you want
reflected_runner.php
assumes the uses some parameters passed in the job to determine which SS instance triggered the job. This is more useful for a shared server scenario where you have multiple discrete instances (ie with separate codebases/DBs) all sharing the same local gearman instancegearman_runner.php
is probably closer to your needs in that it will execute in the context of a SilverStripe instance and grab jobs from any gearman server, but be aware that the way it's written it'll grab any job, regardless of the source SS instance. If in the scenario you describe those source instances are just load balanced replicas of the same 'discrete instance' (ie same DB) that won't be an issue. In any case, it's likely you'll want to create your own runner.php script with appropriate config details for which gearman server to connect to for listening for jobs. The current scripts at present aren't really generic enough at present.
Thanks, setting the server info via Injector works great.
The gearman_runner.php seems to work for my needs, if I change the $worker->addServer call to contain the server data.
I think it would be nice to pass the server data as parameters to the runner. I saw that you copy the first argument to the get parameter 'url' in line 47. Is there any reason for this?
Just in case someone is looking for a way to do this...
I changed the gearman_runner.php
to pull the gearman server address from the config as well:
$confLocator = Injector::inst()->getConfigLocator();
$serverConfig = $confLocator->locateConfigFor('GearmanService');
$worker = new \Net\Gearman\Worker();
$worker->addServer($serverConfig["properties"]["host"]);
In the config.yml
the config needs to reside under properties:
Injector:
GearmanService:
properties:
host: myhostname
Same could be done with the port, if needed. This way the same config works for gearman workers as for job creation.
From what I can tell the gearman server config is currently hard coded to be localhost:4730 in multiple places. I would like to use this module (and silverstripe-queuedjobs) in a setup where we:
I guess the solution would be to move the server config to the config system / yml. Maybe allow to pass it as parameters to the runner script.
Is this correct and if yes would you be interested in a pull request for those changes?