Is it possible to trigger a job from the console

question

#1
class ProcessJob <  ApplicationJob
  def begin_task
    # Do some task 
  end
end

Can I trigger this job from the jets console using the following -
ProcessJob.perform_later(:begin_task)

And I mean not only in dev mode, but production as well.

Thanks.


#2

ProcessJob.perform_later(:begin_task) triggers the remote Lambda function regardless of JETS_ENV.

Examples:

$ JETS_ENV=development jets console
> ProcessJob.perform_later(:begin_task) # triggers the remote lambda function on the deployed demo-dev app

And

$ JETS_ENV=production jets console
> ProcessJob.perform_later(:begin_task) # triggers the remote lambda function on the deployed demo-prod app

Another way of putting it:

perform_later always triggers the remote lambda function. perform_now works within the same current process. If that process is on your local machine, it’s local. If that process is on lambda, it’s within lambda.

Hope that helps.


#3

Got it, thanks for the quick response.

So basically perform_now will error out in a JETS_ENV=production jets console scenario?


#4

:face_with_monocle: If production has not been deployed, it would error. If production has been deployed, it should work.