partial #2816 - cron - logs
This commit is contained in:
parent
6686180800
commit
6701018fa4
@ -20,6 +20,7 @@ class Crunchbutton_Cron_Log extends Cana_Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function start(){
|
public static function start(){
|
||||||
|
|
||||||
$crons = Crunchbutton_Cron_Log::q( "SELECT * FROM cron_log WHERE `interval` != '' AND interval_unity > 0" );
|
$crons = Crunchbutton_Cron_Log::q( "SELECT * FROM cron_log WHERE `interval` != '' AND interval_unity > 0" );
|
||||||
if( $crons->count() ){
|
if( $crons->count() ){
|
||||||
Log::debug( [ 'type' => 'cron-jobs', 'method' => 'start', 'desc' => 'working with ' . $crons->count() . ' cron jobs' ] );
|
Log::debug( [ 'type' => 'cron-jobs', 'method' => 'start', 'desc' => 'working with ' . $crons->count() . ' cron jobs' ] );
|
||||||
@ -44,9 +45,9 @@ class Crunchbutton_Cron_Log extends Cana_Table {
|
|||||||
$job = $this;
|
$job = $this;
|
||||||
|
|
||||||
// Timeout to run it async
|
// Timeout to run it async
|
||||||
Cana::timeout( function() use( $job ) {
|
// Cana::timeout( function() use( $job ) {
|
||||||
$job->go();
|
$job->go();
|
||||||
} );
|
// } );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,13 +129,14 @@ class Crunchbutton_Cron_Log extends Cana_Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function go(){
|
public function go(){
|
||||||
|
$this->log( 'go', $this->class );
|
||||||
if( class_exists( $this->class ) ){
|
if( class_exists( $this->class ) ){
|
||||||
$job = new $this->class;
|
$job = new $this->class;
|
||||||
if( is_a( $job, 'Crunchbutton_Cron_Log' ) ){
|
if( is_a( $job, 'Crunchbutton_Cron_Log' ) ){
|
||||||
if( method_exists( $job, 'run' ) ){
|
if( method_exists( $job, 'run' ) ){
|
||||||
$this->log( 'run', 'running' );
|
|
||||||
$job->id_cron_log = $this->id_cron_log;
|
$job->id_cron_log = $this->id_cron_log;
|
||||||
$job->run();
|
$job->run();
|
||||||
|
$this->log( 'go', $this->class . ' called run' );
|
||||||
} else {
|
} else {
|
||||||
$this->log( 'run', 'error: ' . $this->class . ' doesnt have the method run' );
|
$this->log( 'run', 'error: ' . $this->class . ' doesnt have the method run' );
|
||||||
}
|
}
|
||||||
@ -182,6 +184,6 @@ class Crunchbutton_Cron_Log extends Cana_Table {
|
|||||||
public function log( $method, $message ){
|
public function log( $method, $message ){
|
||||||
$data = [ 'type' => 'cron-jobs', 'method' => $method, 'message' => $message, 'desc' => $this->description, 'id_cron_log' => $this->id_cron_log ];
|
$data = [ 'type' => 'cron-jobs', 'method' => $method, 'message' => $message, 'desc' => $this->description, 'id_cron_log' => $this->id_cron_log ];
|
||||||
Log::debug( $data );
|
Log::debug( $data );
|
||||||
|
echo $method . ':' $message . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user