Giter Site home page Giter Site logo

wp-minions's Introduction

WP Minions

Provides a framework for using job queues with WordPress for asynchronous task running. Provides an integration with Gearman and RabbitMQ out of the box.

Support Level Build Status Release Version GPLv2 License

Caution

As of 12 April 2024, this project is archived and no longer being actively maintained.

Background & Purpose

As WordPress becomes a more popular publishing platform for increasingly large publishers, with complex workflows, the need for increasingly complex and resource-intensive tasks has only increased. Things like generating reports, expensive API calls, syncing users to mail providers, or even ingesting content from feeds all take a lot of time or a lot of memory (or both), and commonly can't finish within common limitations of web servers, because things like timeouts and memory limits get in the way.

WP Minions provides a few helper functions that allow you to add tasks to a queue, and specify an action that should be called to trigger the task, just hook a callback into the action using add_action()

During configuration, a number of minions (workers) are specified. As minions are free, they will take the next task from the queue, call the action, and any callbacks hooked into the action will be run.

In the situation of needing more ram or higher timeouts, a separate server to process the tasks is ideal - Just set up WordPress on that server like the standard web servers, and up the resources. Make sure not to send any production traffic to the server, and it will exclusively handle tasks from the queue.

Installation

  1. Install the plugin in WordPress. If desired, you can download a zip and install via the WordPress plugin installer.

  2. Create a symlink at the site root (the same directory as wp-settings.php) that points to the wp-minions-runner.php file in the plugin (or copy the file, but a symlink will ensure it is updated if the plugin is updated)

  3. Define a unique salt in wp-config.php so that multiple installs don't conflict.

define( 'WP_ASYNC_TASK_SALT', 'my-unique-salt-1' );

Note: If you are using multisite, you'll also have to add the following to your wp-config.php file, after the block with the multisite definitions. This is due to the fact that multisite relies on HTTP_HOST to detect the site/blog it is running under. You'll also want to make sure you are actually defining DOMAIN_CURRENT_SITE in the multisite configuration.

if ( ! isset( $_SERVER['HTTP_HOST'] ) && defined( 'DOING_ASYNC' ) && DOING_ASYNC ) {
  $_SERVER['HTTP_HOST'] = DOMAIN_CURRENT_SITE;
}
  1. Next, you'll need to choose your job queue system. Gearman and RabbitMQ are supported out of the box.

Gearman

There are a few parts to get this all running. First, the Gearman backend needs to be setup - this part will vary depending on your OS. Once that is complete, we can install the WordPress plugin, and set the configuration options for WordPress.

Backend Setup - CentOS 6.x

  1. You'll need the EPEL repo for gearman, and the REMI repo for some of the php packages. Make sure to enable the appropriate remi repo for the version of php you are using.
    • wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm && rpm -Uvh epel-release-6*.rpm
    • wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm && rpm -Uvh remi-release-6*.rpm
    • rm *.rpm
  2. Make sure that remi is enabled, as well as any specific version of php you may want in /etc/yum.repos.d/remi.repo
  3. yum install gearmand php-pecl-gearman python-pip
  4. easy_install supervisor
  5. chkconfig supervisord on && chkconfig gearmand on
  6. If everything is running on one server, I would recommend limiting connections to localhost only. If not, you'll want to set up firewall rules to only allow certain clients to connect on the Gearman port (Default 4730)
  • edit /etc/sysconfig/gearmand - set OPTIONS="--listen=localhost"
  1. service gearmand start

Backend Setup - CentOS 7.x

  1. You'll need the EPEL repo for gearman, and the REMI repo for some of the php packages.
    • yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    • yum install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
  2. yum install gearmand php-pecl-gearman --enablerepo=remi-php<php version on your system>. For example, if you are using php 7.2 your command would look like this yum install gearmand php-pecl-gearman --enablerepo=remi-php72
  3. Optionally, install supervisord if you prefer it
    • yum install python-pip
    • easy_install supervisor
  4. If everything is running on one server, I would recommend limiting connections to localhost only. If not, you'll want to set up firewall rules to only allow certain clients to connect on the Gearman port (Default 4730)
    • edit /etc/sysconfig/gearmand - set OPTIONS="--listen=localhost"
  5. systemctl enable gearmand
  6. systemctl start gearmand

Backend Setup - Ubuntu

As you go through this, you may need to install additional packages, if you do not have them already, such as php-pear or a php*-dev package

  1. apt-get update
  2. apt-get install gearman python-pip libgearman-dev supervisor
  3. pecl install gearman
  4. Once pecl install is complete, it will tell you to place something like extension=gearman.so into your php.ini file - Do this.
  5. update-rc.d gearman-job-server defaults && update-rc.d supervisor defaults
  6. If everything is running on one server, I would recommend limiting connections to localhost only. If not, you'll want to set up firewall rules to only allow certain clients to connect on the Gearman port (Default 4730)
  • edit /etc/default/gearman-job-server - set PARAMS="--listen=localhost"
  1. service gearman-job-server restart

Supervisor Configuration

Filling in values in <brackets> as required, add the following config to either /etc/supervisord.conf (CentOS) or /etc/supervisor/supervisord.conf (Ubuntu)

[program:my_wp_minions_workers]
command=/usr/bin/env php <path_to_wordpress>/wp-minions-runner.php
process_name=%(program_name)s-%(process_num)02d
numprocs=<number_of_minions>
directory=<path_to_temp_directory>
autostart=true
autorestart=true
killasgroup=true
user=<user>
  • path_to_wordpress: Absolute path to the root of your WordPress install, ex: /var/www/html/wordpress
  • number_of_minions: How many minions should be spawned (How many jobs can be running at once).
  • path_to_temp_directory: probably should just be the same as path_to_wordpress.
  • user: The system user to run the processes under, probably apache (CentOS), nginx (CentOS), or www-data (Ubuntu).
  • You can optionally change the "my_wp_minions_workers" text to something more descriptive, if you'd like.

After updating the supervisor configuration, restart the service (CentOS or Ubuntu)

systemctl restart supervisord
service supervisor restart

Systemd Configuration (CentOS 7.x)

Filling in values in <brackets> as required, add the following to /etc/systemd/system/[email protected]

[Unit]
Description=WP-Minions Runner %i
After=network.target

[Service]
PIDFile=/var/run/wp-minions-runner.%i.pid
User=<user>
Type=simple
ExecStart=/usr/bin/env php <path_to_wordpress>/wp-minions-runner.php
Restart=always

[Install]
WantedBy=multi-user.target
  • path_to_wordpress: Absolute path to the root of your WordPress install, ex: /var/www/html/wordpress
  • user: The system user to run the processes under, probably apache (CentOS), nginx (CentOS), or www-data (Ubuntu).

Reload systemd:

systemctl daemon-reload

Enable and start as many runners as you'd like to have running:

systemctl enable wp-minions-runner@{1..n}
systemctl start wp-minions-runner@{1..n}

Where 'n' is the number of processes you want.

WordPress Configuration

Define the WP_MINIONS_BACKEND constant in your wp-config.php. Valid values are gearman or rabbitmq. If left blank, it will default to a cron client.

define( 'WP_MINIONS_BACKEND', 'gearman' );

If your job queue service not running locally or uses a non-standard port, you'll need define your servers in wp-config.php

# Gearman config
global $gearman_servers;
$gearman_servers = array(
  '127.0.0.1:4730',
);
# RabbitMQ config
global $rabbitmq_server;
$rabbitmq_server = array(
  'host'     => '127.0.0.1',
  'port'     => 5672,
  'username' => 'guest',
  'password' => 'guest',
);

Note: On RabbitMQ the guest/guest account is the default administrator account, RabbitMQ will only allow connections connections on that account from localhost. Connections to any non-loopback address will be denied. See the RabbitMQ manual on [user management](https://www.rabbitmq.com/rabbitmqctl.8.html#User_Management) and [Access Control](https://www.rabbitmq.com/rabbitmqctl.8.html#Access_Control) for information on adding users and allowing them access to RabbitMQ resources.

## MySQL Persistent Queue (Recommended)

By default, gearman will store the job queue in memory. If for whatever reason the gearman service goes away, so does the queue. For persistence, you can optionally use a MySQL database for the job queue:

#### CentOS

Edit the gearman config at ```/etc/sysconfig/gearmand```, adding the following to the OPTIONS line (or creating the line, if it doesn't exist yet), inserting database credentials as necessary:
```sh
OPTIONS="-q MySQL --mysql-host=localhost --mysql-port=3306 --mysql-user=<user> --mysql-password=<password> --mysql-db=gearman --mysql-table=gearman_queue"

Ubuntu

Edit the gearman config at /etc/default/gearman-job-server, adding the following to the PARAMS line (or creating the line, if it doesn't exist yet), inserting database credentials as necessary:

PARAMS="-q MySQL --mysql-host=localhost --mysql-port=3306 --mysql-user=<user> --mysql-password=<password> --mysql-db=gearman --mysql-table=gearman_queue"

Note: For some setups, the above will not work as /etc/default/gearman-job-server does not get read. If you don't see the persistent queue setup then:

  1. Create a gearman db in mysql (the database must be present in the database, but when gearmand is initialized the first time it will create the table).
  2. Create a file in /etc/gearmand.conf
  3. In the file paste the configuration all on one line:
-q MySQL --mysql-host=localhost --mysql-port=3306 --mysql-user=<user> --mysql-password=<password> --mysql-db=gearman --mysql-table=gearman_queue

Then restart the gearman-job-server: sudo service gearman-job-server restart.

Verification

Once everything is installed, you can quickly make sure your job queue is accepting jobs with the test-client.php and test-worker.php files located in the system-tests/YOURQUEUE directory. The worker is configured to reverse any text passed to it. In the client file, we pass "Hello World" to the worker.

In one window, run php test-worker.php - You'll now have one worker process running, waiting for jobs.

In another window, run php test-client.php "Hello World" - You should see "dlroW olleH" printed on your screen.

ctrl-c will stop the worker once you are done testing.

Usage

Once configured and activated, you'll have access to wp_async_task_add(). If you are at all familiar with wp_schedule_single_event(), the way wp_async_task_add() works should be very familiar to you.

The function takes up to three arguments, the first of which is required:

  1. $hook: This is the name of the action hook to execute when the job runs. Your callback function should hook into this with add_action( $hook, $callback )
  2. $args: This is optional, and defaults to an empty array. You can pass an array of arbitrary data to this, and it will be passed to your callback function.
  3. $priority: This is optional, and defaults to "normal". Other valid options are "high" or "low". High priority jobs will be run before normal priority jobs, even if they normal priority job has been in the queue longer.

Set an option in the database, when a worker becomes available:

// Add a task, that will call the "myplugin_update_option" action when it is run
wp_async_task_add( 'myplugin_update_option', array( 'mykey' => 'myvalue' ) );

function myplugin_update_option_callback( $args ) {
	// In reality, you are probably doing a lot of resource intensive work here
	update_option( 'my-option-name', $args['mykey'] );
}

// Add the action that links the task and the callback.
// Notice the hook below is the same as the hook provided to wp_async_task_add.
add_action( 'myplugin_update_option', 'myplugin_update_option_callback' );

Once a worker is free, and runs the above task, you'd have an option called "my-option-name" in the options table, with a value of "myvalue", since "myvalue" was passed in via the $args

Customization

The following constants can be used to customize the behaviour of WP Minions.

  1. WP_MINIONS_JOBS_PER_WORKER - The number of jobs to execute per Worker, default is 1. Running multiple jobs per worker will reduce the number workers spawned, and can significantly boost performance. However too large a value will cause issues if you have memory leaks. Use with caution.

  2. WP_MINIONS_CLIENT_CLASS - You can also alter the Client class used to send jobs to your job queue. It should match the interface of \WpMinions\Client.

  3. WP_MINIONS_WORKER_CLASS - Similarly you can alter the Worker class used to execute jobs. It should match the interface of \WpMinions\Worker.

Issues

If you identify any errors or have an idea for improving the plugin, please open an issue. We're excited to see what the community thinks of this project, and we would love your input!

Support Level

Archived: This project is no longer maintained by 10up. We are no longer responding to Issues or Pull Requests unless they relate to security concerns. We encourage interested developers to fork this project and make it their own!

Like what you see?

wp-minions's People

Contributors

cadwell avatar cmmarslender avatar dsawardekar avatar dustinrue avatar jeffpaul avatar johnpbloch avatar kish2011 avatar nerrad avatar parhamg avatar petenelson avatar selul avatar tlovett1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wp-minions's Issues

Test against WordPress 5.9

Is your enhancement related to a problem? Please describe.
Once WordPress 5.9 is released, we'll want to test WP Minions to see if any incompatibility issues arise.

Describe the solution you'd like

  • test WP Minions on WordPress 5.9
  • open issues for any incompatibilities noted in testing
  • resolve issues identified in testing
  • bump "tested up to" version
  • if code changes needed due to incompatibilities, ship a release

Designs
n/a

Describe alternatives you've considered
none

Additional context
none

No way to specify alternate gearman server in test scripts

In some situations, the actual gearman server/queue may be on a different server than the worker or client we are trying to test.

Should possibly allow passing alternate host for server via args when running the client and worker test scripts.

Delaying the jobs to be run

I need to delay the queue to 30 seconds before it's run.

Is any method I can use or just use sleep() function from PHP?

Thanks

Uncaught Error: Class 'WpMinions\Plugin' not found

Uncaught Error: Class 'WpMinions\Plugin' not found

Getting these errors when I am trying to call wp_async_task_add this?

Fatal error: Uncaught Error: Class 'WpMinions\Plugin' not found in /Applications/MAMP/htdocs/woocommerce/wp-content/plugins/WP-Minions/wp-minions.php:30 Stack trace: #0 /Applications/MAMP/htdocs/woocommerce/wp-content/plugins/WP-Minions/wp-minions.php(64): wp_async_task_add('transition_post...', Array) #1 /Applications/MAMP/htdocs/woocommerce/wp-settings.php(362): include_once('/Applications/M...') #2 /Applications/MAMP/htdocs/woocommerce/wp-config.php(103): require_once('/Applications/M...') #3 /Applications/MAMP/htdocs/woocommerce/wp-load.php(37): require_once('/Applications/M...') #4 /Applications/MAMP/htdocs/woocommerce/wp-admin/admin.php(34): require_once('/Applications/M...') #5 /Applications/MAMP/htdocs/woocommerce/wp-admin/plugins.php(10): require_once('/Applications/M...') #6 {main} thrown in /Applications/MAMP/htdocs/woocommerce/wp-content/plugins/WP-Minions/wp-minions.php on line 30

Feature: remove need for client code to set an action.

Currently client code sends a string representing a registered "action" that will be used to execute the actual callback on the code. I propose a slight improvement to WPGears so that client code just sends in the actual callback and wpgears will set and call its own action.

Example for how would work is in this gist https://gist.github.com/nerrad/b1c651bbe60466c064805216a9045756 (which was created for #12).

If there's interest, I can do a pull request?

Jobs not being added to Gearman queue.

This is the third time I have set up WP Minions, normally no problem, but this time I'm having major issues :(

First up, server:

  • Centos: 7
  • PHP: 7.4.15
  • MySQL: mysql Ver 15.1 Distrib 5.5.68-MariaDB
  • Wordpress 5.6.1
  • Plugin: 4.1.0

I think it is also worth noting that the server uses Plesk, however I have full control of this server via SSH etc. I don't believe this is an issue either however we are running Wordpress through a Nginx > Apache reverse proxy.

Following the instructions as normal (note i have changed some bits for security):

wp-config.php

        define('WP_MINIONS_BACKEND', 'gearman');
        define('WP_ASYNC_TASK_SALT', 'somesalt-gearman');

Gearman is running with the database information added to /etc/sysconfig/gearmand

OPTIONS="--listen=localhost --verbose=INFO  -q MySQL --mysql-host=localhost --mysql-port=3306 --mysql-user=someusr --mysql-password=somepassword --mysql-db=somedb--mysql-table=wt_tp_gearman_queue"

And when restarted I see the table created within the database.

Supervisor is running and working, as expected it's used on another application so this should be fine.
supervisorctl status

laravel-worker:laravel-worker_00       RUNNING   pid 23663, uptime 1:41:38
my-minions:my-minions-00   RUNNING   pid 23664, uptime 1:41:38

The service is setup also
/etc/systemd/system/[email protected]

[Unit]
Description=WP-Minions Runner %i
After=network.target

[Service]
PIDFile=/var/run/wp-minions-runner.%i.pid
User=myuser
Type=simple
ExecStart=/usr/bin/php /var/www/vhosts/somesite.com/httpdocs/wp-minions-runner.php
Restart=always

[Install]
WantedBy=multi-user.target

And enabling and starting with the following seems fine also

systemctl enable wp-minions-runner@{1..1}
systemctl start wp-minions-runner@{1..1}

However, firing any event simply does not pass the task to Gearman it seems, i'm not seeing it in the queue table nor any errors.

Running
gearadmin --status

somesalt-gearman:WP_Async_Task	0	0	2

And looking at the Gearman logs I can see a connection and no errors:

   INFO 2021-02-24 13:21:10.000000 [  main ] Accepted connection from ::3534:3937:3800:0%1483259374:57180
   INFO 2021-02-24 13:21:10.000000 [  main ] Accepted connection from ::3537:3138:3000:0%1483259374:57182

I'm running out of ideas now! Any help with this would be appreciated!

PHPUNIT_RUNNER not defined

In wp-minions.php the plugins_loaded action is stuck in a loop where PHPUNIT_RUNNER is never defined. When tailing supervisorctl I the wp_async_task_init gets called as does \WpMinions\Plugin::get_instance(); but then simply continues looping back to the plugins_loaded function.

add_action( 'plugins_loaded', function() {
	// Init
	if ( ! defined( 'PHPUNIT_RUNNER' ) ) {
		wp_async_task_init();
	}
}, 9 );

System Info

  • WP CORE 5.6
  • WP Minions plugin 4.1.0
  • PHP 7.4
  • Centos7

Possible issue with caching $blog_id on `\WpGears\Gearman\Client`

This issue is still an assumption, it hasn't been proven yet. I'll be adding to it as I investigate but wanted to get it written up in case there's others that can confirm the behaviour we experienced.

I've implemented WPGears on a WP multisite install to handle the sending of notifications for users of our platform. This past week we tried upping the number of blogs processed per worker and started seeing some cross pollution of blog_id where notifications were processed in the wrong blog context (this doesn't happen when jobs per worker remains at 1)

One thing that is unique about our setup that likely contributed to this issue being exposed is if while a job is being executed, we experience an error that prevents the notification being processed/sent at that moment in time then we add the job back to the queue before exiting. I think this is what triggers the cross blog pollution because when a job is executing via WPGears\Gearman\Worker the blog has been switched to the blog_id for the job, but then if while IN that switch, \WpGears\Gearman\Client::add is called, that will end up using the blog_id cached in the worker from when the client was first instantiated.

So one way of possibly handling this is to not cache the blog_id and always return whatever the value of get_current_blog_id() is. Another possibility would be to only cache the blog_id when the JOBS_PER_WORKER config is at 1 (which kind of defeats the purpose of having it cached anyways).

Another potential danger of caching the blog_id that may surface in another context is if \WPGears\Gearman\Client is instantiated at the beginning of a request, and then add_job is done in the context of a switched blog by other code, the job will end up getting added for the wrong blog_id (the blog from when it was instantiated). So it seems that the best option here would be to not cache.

Performance improvements over action scheduler?

Hi guys

I'm building out a WordPress based app at the moment. We have full control over the server stack, so we could easily implement this instead of WP Background Processing or Action Scheduler. However, RabbitMQ / Gearman would be running on the same server as the site. It wouldn't be on a separate server.

Is there any performance benefit to offloading jobs to a separate service if the service is on the same machine?

Cheers

WP-Gears from WP CLI

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!');
}

$args not being passed into callback function

Hi, I've copied and pasted the example into functions.php to see if it works, and the $args passed into the callback function are not working. Any ideas why this might be happening?

Thanks,
Zach

supervisord

Maybe a stupid question, but if gearman is running on a separate server, supervisord should run on the same server as WordPress (i.e. it's used to control wp-gears-runner.php) ?

Parameter to worker callback is a string, not an array

If I print_r($args) in wp_gears_heartbeat_worker_callback below, it returns the string "gettime", not an array.

wp_async_task_add( 'wp_gears_heartbeat_worker', array( 'action' => 'gettime' ), 'high' );

if ( ! class_exists( 'WP_Gears_Get_Time_Worker' ) ) {
    class WP_Gears_Get_Time_Worker {
        static function wp_gears_heartbeat_worker_callback( $args ) {
            //if ( 'gettime' == $args['action']) { // doesn't work, $args is a string with value = 'gettime'
            sleep( 1 ); // without, you'll  get ,in supervisor, "INFO gave up: nn_worker-00 entered FATAL state, too many start retries too quickly"
            update_option( 'wp-gears-heartbeat-time_' . $_GET['doing_wp_cron'],   time() ); // $_GET['doing_wp_cron'] is unique
            //}
        }
    }
}
add_action( 'wp_gears_heartbeat_worker', array( 'WP_Gears_Get_Time_Worker', 'wp_gears_heartbeat_worker_callback' ) );

Include GearmanJob instance as argument for job action?

Is there opposition to including the instance of GearmanJob as an argument on these actions? The primary purpose is so that the instance is exposed for any client code hooking in to do things. An example is I want to log the $job->unique() along with other attributes of what's happening when its being executed.

If no opposition I can whip up a pull request. Something like:

do_action( 'wp_async_task_before_job', $hook, $job );
do_action( 'wp_async_task_before_job_' . $hook, $job );

do_action( $hook, $args, $job );

do_action( 'wp_async_task_after_job', $hook, $job );
do_action( 'wp_async_task_after_job_' . $hook, $job );

readme updates

It's not obvious the level of support provided for this repo, so let's add some clarification.

  • add support level section and badge
  • add release version badge
  • add license file and badge

race condition when running multiple processes (?)

I written a plugin to test WP Gears with the heartbeat API. The idea is to use heartbeat to update status when a gearman job is done. The plugin is at https://gist.github.com/soderlind/a27527c3ed6545f594d7 EDIT, this is the correct url: https://gist.github.com/soderlind/94629e4ae933407d823c

If I run the default 5 processes using supervisor the result is intermittent (i.e. the callback in my plugin i run now and then). I have the following in my /etc/supervisor/supervisord.conf:

[program:wp_gears_worker]
command=/usr/bin/php /srv/www/wp-gears-test/htdocs/wp-gears-runner.php
process_name=%(program_name)s-%(process_num)02d
numprocs=5
directory=/tmp
autostart=true
autorestart=true
killasgroup=true
user=www-data

if I change to numprocs=1 my plugin works as expected

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.