New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

then a job is invoked with .call, .running? does not show it as running #214

Closed
piavka opened this Issue Oct 28, 2016 · 9 comments

Comments

Projects
None yet
2 participants
@piavka

piavka commented Oct 28, 2016

Hey, I'm using the scheduler to run jobs on cron like schedules , and also have an option to invoke the jobs out of schedule which is implemented by calling the .call method of the job
however then job is invoked in such way the .running? shows that job is not running
is this by design or bug ?

@jmettraux

This comment has been minimized.

Show comment
Hide comment
@jmettraux

jmettraux Oct 28, 2016

Owner

Hello,

it's by lack of design.

Owner

jmettraux commented Oct 28, 2016

Hello,

it's by lack of design.

jmettraux added a commit that referenced this issue Oct 28, 2016

@piavka

This comment has been minimized.

Show comment
Hide comment
@piavka

piavka Oct 28, 2016

@jmettraux cool thanks
when to expect a new gem release ? :)

piavka commented Oct 28, 2016

@jmettraux cool thanks
when to expect a new gem release ? :)

@jmettraux

This comment has been minimized.

Show comment
Hide comment
@jmettraux

jmettraux Oct 28, 2016

Owner

Hello,

you're welcome, it's a bit thin for a release. Can you live with job.trigger(Time.now) for the time being? or can you simply leverage http://bundler.io/git.html for now?

Owner

jmettraux commented Oct 28, 2016

Hello,

you're welcome, it's a bit thin for a release. Can you live with job.trigger(Time.now) for the time being? or can you simply leverage http://bundler.io/git.html for now?

@piavka

This comment has been minimized.

Show comment
Hide comment
@piavka

piavka Oct 28, 2016

i cannot use gems deps thought git in production since they are pita to make reliable fir automatic deploy , i might end building a gem and push it to local artifactory

BTW if job is unscheduled can i still use the new run method? also can i schedule job back from unscheduled state to scheduled or i'd have to redefine it from scratch ?

piavka commented Oct 28, 2016

i cannot use gems deps thought git in production since they are pita to make reliable fir automatic deploy , i might end building a gem and push it to local artifactory

BTW if job is unscheduled can i still use the new run method? also can i schedule job back from unscheduled state to scheduled or i'd have to redefine it from scratch ?

@jmettraux

This comment has been minimized.

Show comment
Hide comment
@jmettraux

jmettraux Oct 28, 2016

Owner

BTW if job is unscheduled can i still use the new run method?

I think so.

also can i schedule job back from unscheduled state to scheduled or i'd have to redefine it from scratch ?

I think

scheduler.instance_eval { @jobs.push(job) }

might work.

It could be formalised as

class Rufus::Scheduler::Job
  def reschedule
    @scheduler.instance_eval { @jobs.push(self) }
  end
end
Owner

jmettraux commented Oct 28, 2016

BTW if job is unscheduled can i still use the new run method?

I think so.

also can i schedule job back from unscheduled state to scheduled or i'd have to redefine it from scratch ?

I think

scheduler.instance_eval { @jobs.push(job) }

might work.

It could be formalised as

class Rufus::Scheduler::Job
  def reschedule
    @scheduler.instance_eval { @jobs.push(self) }
  end
end

@jmettraux jmettraux closed this Oct 28, 2016

@piavka

This comment has been minimized.

Show comment
Hide comment
@piavka

piavka Oct 29, 2016

@jmettraux the run methods works great and job is visible as .running?

unfortunately while job is unscheduled or paused (cronjob) invoking .run or .call methods does nothing, is there trick to invoke the job body while it's paused ?

piavka commented Oct 29, 2016

@jmettraux the run methods works great and job is visible as .running?

unfortunately while job is unscheduled or paused (cronjob) invoking .run or .call methods does nothing, is there trick to invoke the job body while it's paused ?

@piavka

This comment has been minimized.

Show comment
Hide comment
@piavka

piavka Oct 29, 2016

@jmettraux i managed to do this with this hack

class Rufus::Scheduler::CronJob
  def trigger_out_of_schedule(time)
    return if (
      opts[:overlap] == false &&
      running?
    )

    @count += 1

    if opts[:blocking]
      do_trigger(time)
    else
      do_trigger_in_thread(time)
    end
  end
end

I'm now using it instead of the new run method too

if you think there is place for this to be merged , let me know and i'll do a PR
tnx

piavka commented Oct 29, 2016

@jmettraux i managed to do this with this hack

class Rufus::Scheduler::CronJob
  def trigger_out_of_schedule(time)
    return if (
      opts[:overlap] == false &&
      running?
    )

    @count += 1

    if opts[:blocking]
      do_trigger(time)
    else
      do_trigger_in_thread(time)
    end
  end
end

I'm now using it instead of the new run method too

if you think there is place for this to be merged , let me know and i'll do a PR
tnx

@jmettraux

This comment has been minimized.

Show comment
Hide comment
@jmettraux

jmettraux Oct 29, 2016

Owner

OK, let me think about it. I want a solution that works for any job.

Owner

jmettraux commented Oct 29, 2016

OK, let me think about it. I want a solution that works for any job.

@jmettraux jmettraux self-assigned this Oct 29, 2016

@jmettraux jmettraux reopened this Oct 29, 2016

jmettraux added a commit that referenced this issue Nov 23, 2016

jmettraux added a commit that referenced this issue Nov 24, 2016

@jmettraux

This comment has been minimized.

Show comment
Hide comment
@jmettraux

jmettraux Nov 24, 2016

Owner

Hello @piavka I've adopted your #trigger_out_of_schedule (renamed it to #trigger_off_schedule).

Please have a look and tell me if it's OK with you.

I'll probably add the Job#reschedule discussed above, then release a 3.3.0.

Thanks a lot!

Owner

jmettraux commented Nov 24, 2016

Hello @piavka I've adopted your #trigger_out_of_schedule (renamed it to #trigger_off_schedule).

Please have a look and tell me if it's OK with you.

I'll probably add the Job#reschedule discussed above, then release a 3.3.0.

Thanks a lot!

@jmettraux jmettraux closed this Nov 27, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment