Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

WP-Gears from WP CLI #3

Closed
soderlind opened this issue Sep 7, 2015 · 2 comments
Closed

WP-Gears from WP CLI #3

soderlind opened this issue Sep 7, 2015 · 2 comments

Comments

@soderlind
Copy link

Hi,

I'm trying to run WP-Gears from WP-CLI, but I can't get it to trigger. I've installed gearman following your guide. Verified that it work using test-client.php and test-worker.php.

Here's my test-plugin: https://gist.github.com/soderlind/a27527c3ed6545f594d7

Here's the output from supervisor.log:

2015-09-06 23:59:03,922 INFO exited: wxr2pdf_wp_gears_workers-04 (exit status 0; expected)
2015-09-06 23:59:04,926 INFO spawned: 'wxr2pdf_wp_gears_workers-04' with pid 21341
2015-09-06 23:59:05,929 INFO success: wxr2pdf_wp_gears_workers-04 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

The wp cli works when I call the "callback" directly from mytest():

function mytest( $args, $assoc_args ) {
    $this->_init();
    list( $file ) = $args;
    self::wp_cli_gears_worker_callback(array('file' => $file));
    WP_CLI::success('Done!');
}
@cmmarslender
Copy link
Contributor

The callback function for the action is only ever loaded if WP_CLI is defined. Since gearman workers are not run in a WP-CLI context, I think you don't have the callback available to the workers. Try moving the callback for your action to a file that is loaded in all contexts (not just wp-cli) and I think it will work.

@soderlind
Copy link
Author

Yepp, you're right. Thank you :)

Updated and working: https://gist.github.com/soderlind/a27527c3ed6545f594d7

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants