2

If I start my background worker for delayed_job, and then submit a job, the job runs but I do not see any terminal output from the job. How do I arrange it so I can see terminal output. I am using ruby on rails in development mode.

I want to do this when I when issue the command bin/delayed_job start.

Obromios
  • 15,408
  • 15
  • 72
  • 127
  • You'll need to set up a logger. See for example https://stackoverflow.com/questions/14631910/logging-in-delayed-job – Gene Oct 03 '17 at 05:19

3 Answers3

2

As suggested by Gene and Shani, you can set up a logger by adding

Delayed::Worker.logger = Logger.new(File.join(Rails.root, 'log', 'delayed_job.log'))

to config/initializers/delayed_job_initializers.rb and then in the running process output using

Delayed::Worker.logger.debug("Log Entry")

and then viewing the output using

tail -f log/delayed_job.log.
Obromios
  • 15,408
  • 15
  • 72
  • 127
1

you can start worker on a rails console. what I do when I want to debug delayed job is

worker = Delayed::Worker.new
worker.start
Shani
  • 2,433
  • 2
  • 19
  • 23
  • That could be useful, but the output from the job helps me monitor its progress, so I want to do this when issue the command ```bin/delayed_job start``` – Obromios Oct 03 '17 at 08:16
  • all the commands listed here https://github.com/collectiveidea/delayed_job/wiki/Delayed-job-command-details you can do set up logger as mentioned by user above and then use the tail command to see the log tail -f log/delayed_job.log – Shani Oct 03 '17 at 09:29
0

Use the bin/rails jobs:work command in a separate terminal window. It will start processing jobs in that terminal without exiting.

If you've put breakpoints or puts statements in your job, you'll see them in the terminal.

Stop the process using CTRL-C.

Hope that helps.

software_writer
  • 3,941
  • 9
  • 38
  • 64