Skip to content

Way to run commands in the block sequentially #696

@kingdonb

Description

@kingdonb

Was #19 closed without a fix? I can't find any mention of "sequential" in the code, not sure how complicated it will be to code but I'd give it a shot if you're still willing to consider a PR. The documentation shows an example with multiple tasks, it is unclear that these won't run sequentially.

every 3.hours do # 1.minute 1.day 1.week 1.month 1.year is also supported
  runner "MyModel.some_process"
  rake "my:rake:task"
  command "/usr/bin/my_great_command"
end

I read this and actually assumed the rake task was meant to run as a pre-requisite to my_great_command and that these commands would be run in order -- this shows what you get when you assume, you get it wrong! I got it wrong.

In my case, we are including documentation strings that are intended to mark up our cron.log with datestamps and they are printed out of order.

How clear and well-organized this looks:

every :day, :at => ['02:15am','08:15am','02:15pm','08:15pm'] do
        command "date"
        command "echo 'Foo the Bar'"
    full_runner "Bar::fooer.foo"
end

every :day, :at => ['02:17am','08:17am','02:17pm','08:17pm'] do
        command "date"
        command "echo 'Bat the Baz'"
    full_runner "Baz::bat.batter_up"
end

every '0 10-22 * * *' do
        command "date"
        command "echo 'Reticulating Splines'"
    full_runner "SplinesController.reticulate_all_splines"
end

every '15 10-22 * * *' do
        command "date"
        command "echo 'Frobnicate the Frobnicator'"
    full_runner "FrobnicatorController.frobnicate"
end

every '20 10-22 * * *' do
        command "date"
        command "echo 'Clinking Glasses'"
    full_runner "Glass.all.each do {|g| g.clink_neighbor}"
end

every '25 10-22 * * *' do
        command "date"
        command "echo 'Calling Taxis'"
    full_runner "ClosingTime::friday.ubers_for_everyone"
end

but look at what you get in cron.log:

Fri Apr  7 20:00:02 UTC 2017
Reticulating Splines
Foo the Bar
Frobnicate the Frobnicator
Fri Apr  7 20:15:02 UTC 2017
Fri Apr  7 20:15:02 UTC 2017
Bat the Baz
Fri Apr  7 20:17:01 UTC 2017
Fri Apr  7 20:20:02 UTC 2017
Clinking Glasses
Calling Taxis
Fri Apr  7 20:25:02 UTC 2017

Not at all what I was trying to achieve. Not sure now how to get there from here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions