mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 02:36:28 +00:00 
			
		
		
		
	New cronjob code.
This commit is contained in:
		
							
								
								
									
										65
									
								
								app/Console/Commands/Cron.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								app/Console/Commands/Cron.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,65 @@ | ||||
| <?php | ||||
|  | ||||
| namespace FireflyIII\Console\Commands; | ||||
|  | ||||
| use FireflyIII\Exceptions\FireflyException; | ||||
| use FireflyIII\Support\Cronjobs\RecurringCronjob; | ||||
| use Illuminate\Console\Command; | ||||
|  | ||||
| /** | ||||
|  * Class Cron | ||||
|  */ | ||||
| class Cron extends Command | ||||
| { | ||||
|     /** | ||||
|      * The console command description. | ||||
|      * | ||||
|      * @var string | ||||
|      */ | ||||
|     protected $description = 'Runs all Firefly III cron-job related commands. Configure a cron job according to the official Firefly III documentation.'; | ||||
|     /** | ||||
|      * The name and signature of the console command. | ||||
|      * | ||||
|      * @var string | ||||
|      */ | ||||
|     protected $signature = 'firefly:cron'; | ||||
|  | ||||
|     /** | ||||
|      * Create a new command instance. | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
|     public function __construct() | ||||
|     { | ||||
|         parent::__construct(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Execute the console command. | ||||
|      * | ||||
|      * @return mixed | ||||
|      */ | ||||
|     public function handle(): int | ||||
|     { | ||||
|         $recurring = new RecurringCronjob; | ||||
|         try { | ||||
|             $result = $recurring->fire(); | ||||
|         } catch (FireflyException $e) { | ||||
|             $this->error($e->getMessage()); | ||||
|  | ||||
|             return 0; | ||||
|         } | ||||
|         if (false === $result) { | ||||
|             $this->line('The recurring transaction cron job did not fire.'); | ||||
|         } | ||||
|         if (true === $result) { | ||||
|             $this->line('The recurring transaction cron job fired successfully.'); | ||||
|         } | ||||
|  | ||||
|         $this->info('More feedback on the cron jobs can be found in the log files.'); | ||||
|  | ||||
|         return 0; | ||||
|     } | ||||
|  | ||||
|  | ||||
| } | ||||
| @@ -52,6 +52,18 @@ class Kernel extends ConsoleKernel | ||||
|      */ | ||||
|     protected function schedule(Schedule $schedule): void | ||||
|     { | ||||
|         $schedule->job(new CreateRecurringTransactions(new Carbon))->daily(); | ||||
|         $schedule->call(function() { | ||||
|             echo "\n"; | ||||
|             echo '------------'; | ||||
|             echo "\n"; | ||||
|             echo wordwrap('Firefly III no longer users the Laravel scheduler to do cron jobs! Please read the instructions here:'); | ||||
|             echo "\n"; | ||||
|             echo 'https://firefly-iii.readthedocs.io/en/latest/'; | ||||
|             echo "\n\n"; | ||||
|             echo 'Disable this cron job!'; | ||||
|             echo "\n"; | ||||
|             echo '------------'; | ||||
|             echo "\n"; | ||||
|         })->everyMinute(); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user