Advanced Queue Setup In CLI mode - mailchimp/mc-woocommerce GitHub Wiki
This guide details the setup of an advanced queue in CLI mode for the Mailchimp WooCommerce plugin, enhancing performance by running processes in the background, independent of web traffic.
Prerequisites
- WP-CLI installed.
- Knowledge of WP-CLI and WordPress installation locations on your server.
- Ability to edit the
functions.php
file, preferably using a child theme or suitable plugin.
Disabling the Default Queue Runner
-
Edit
functions.php
File: Include the following code:function asdds_disable_default_runner() { if ( class_exists( 'ActionScheduler' ) ) { remove_action( 'action_scheduler_run_queue', array( ActionScheduler::runner(), 'run' ) ); } } add_action( 'init', 'asdds_disable_default_runner', 10 );
Running the Queue Process
Manual
Run the queue manually using WP-CLI:
wp --url=https://examplestore.com --path=/full/path/to/install/ action-scheduler run
Stop with control
+ c
.
Automatic
- Set up a cron job or use a process manager like Monit or Supervisord.
- For cron, edit the crontab:
Add:crontab -e
Or use a process manager with:* * * * * wp --url=https://examplestore.com --path=/full/path/to/install/ action-scheduler run
/usr/bin/wp --url=http://yourdomain.com --path=/full/path/to/install/ queue listen