SproutCMS

This is the code documentation for the SproutCMS project

class WorkerCtrl

Functions to update and report on worker status

Extending this class

<?php
/**
* New class description goes here
* 
* @author Your Name, 2024-05-02
**/
class NewClassName extends WorkerCtrl {
    
    /**
    * Return the status and metric values for a given worker job.
    * 
    * Statuses are:
    *   'Prepared', 'Running', 'Success', 'Failed'.
    * 
    * Returns an array of ['status', 'metric1val', 'metric2val', 'metric3val'], or NULL on error.
    **/
    public function getStatus ($job_id) {
        // Method code goes here
    }
    
    /**
    * Looks in a few places for a PHP binary
    **/
    private function findPhp () {
        // Method code goes here
    }
    
    /**
    * Starts a new worker
    * Workers are run in their own process (using the PHP CLI)
    * 
    * The first argument is the class name
    * Additional arguments can be provided directly in the function call
    * 
    * Return value is an array with the following keys
    *   job_id    The ID of the new job
    *   log_url   URL to view ongoing status and log
    **/
    public function start (string $class_name) {
        // Method code goes here
    }
    
}
?>