last day (15 days later) » 

4:04 PM
0
A: Scheduled Jobs and Custom Clock Processes with Clockwork

ShivamDYou need to do the following: Firstly install the clockwork gem. In your lib folder create a clock.rb require 'clockwork' require './config/boot' require './config/environment' module Clockwork handler do |job| puts "Running #{job}" end every(1.day, 'Creating Cycle', :at => '22:...

 
Hey thanks for your help, I got an error when I tried running it on Heroku, I updated my question. I have the procfile set up exactly like yours
 
What version of rails are you using?
 
rails version 4.1.0
 
What happens when run "clockwork lib/clock.rb" from the terminal
 
it produces the same error
 
4:04 PM
Open your console 'rails c' and try running 'Delayed::Job.enqueue FilterJob.new' To ensure that the delayed job is setup properly. You have the gem installed right?
 
Yes I have the gem installed, I still get NameError: uninitialized constant FilterJob
 
Hey I don't think the issue is with clockwork, but more with DelayedJob itself.
10
Q: uninitialized constant Delayed::Job

GerI've added the delayed_job gem to my gemfile and installed correctly but when I try to run the following line: Delayed::Job.enqueue do_it(), 0, 1.minutes.from_now.getutc I get the error 'uninitialized constant Delayed::Job' Can somebody explain what i need to do here? I've tried running 'rake...

Maybe these might help you
 
Hmm I did that a while ago since I have other delayed jobs in my app that work already
class FilterJob

  require 'open-uri'


def perform

  timenow = Time.now.to_i

  Stream.all.each do |stream|

  if timenow >= stream.totallength + stream.reprogrammed_at.to_i

####################################################################################
  stream.playlists.each do |playlist|

     doc = Nokogiri::HTML(open("https://www.youtube.com/playlist?list=#{playlist.playlist_id}"))

        doc.css("[data-video-id]").each do |el|
          begin
          @scraped_id = el.attr('data-video-id')
this is the full job I want to run
 
where is this file located?
In the same place as the other jobs? If not, then which folder? The lib folder. I am not sure how you have everything structured but you might have to have this in the config
config.autoload_paths += Dir["#{config.root}/lib/**/"]
^If your job is in the lib directory, but might as well add this because you have your clockwork file in there.
 
its in the same folder as clock.rb
teh lib folder
your saying I should add config.autoload_paths += Dir["#{config.root}/lib/**/"] to my config.ru file?
or should I place it in config/application.rb ?
 
4:18 PM
application.rb
That should do the trick!
 
it should be config.autoload_paths << Rails.root.join('lib')?
and does it go in the class Application < Rails::Aplication block in application.rb ?
 
yes
then exit and re enter your console and try again. Also restart your server
 
thanks man it executes the job but im not sure the code in my job is working correctly
 
Great
At least this issue is solved
 
4:39 PM
yes thanks a lot !!!
 
4:55 PM
Sweet if you could upvote the answer that would be great.
 

last day (15 days later) »