Running Jobs
There are several ways to run a job...
Via the GUI
Click "Run Job" to add it to the Laravel queue. In development mode, you also need to run scripts/artisan.sh queue:dev to process the queue.
Or click the dropdown > Run in Browser to run the job directly in the browser - this is useful for seeing the SQL in Debugbar, but it may time out on large sync jobs.
Via the CLI
scripts/artisan.sh sync [--trigger="trigger"] <class> [record-id] [record-name]
# e.g.
scripts/artisan.sh sync SyncCrmCustomerAccountsToKbClientPages
scripts/artisan.sh sync SyncCrmCustomerAccountsToKbClientPages "14275503-6f26-7c81-6d23-4c4fec3186b1" "Alberon"
Note: If you use dd (or similar) within the job while developing, you may find that the job refuses to run because it is "already running". You can force the job to run by adding --force.
Via PHP Code
This is the same as any other Laravel job:
SyncCrmCustomerAccountsToKbClientPages::dispatch('trigger');
SyncCrmCustomerAccountsToKbClientPages::dispatch('trigger', '14275503-6f26-7c81-6d23-4c4fec3186b1', 'Alberon');
To run it synchronously, e.g. in unit tests:
SyncCrmCustomerAccountsToKbClientPages::dispatchNow('unit tests');
Recording the Trigger
When running a job via the CLI or PHP code, the "trigger" argument should be written in a form that makes sense when written as "Triggered by <trigger>". For example:
Triggered by Vladimir Halama updating account 'Reading Phoenix Choir' (766d9d5e-f5fa-5728-26ab-4e9587eab09b) in SugarCRMTriggered by alberon@kennington.alberon.co.uk via Artisan CLITriggered by cron job