don't try to combine @shortcut jobs
This commit is contained in:
parent
51a6b3720a
commit
6bf363b723
@ -112,7 +112,7 @@ module Whenever
|
|||||||
# them into one that runs on the 2nd minute at the 3rd and 4th hour.
|
# them into one that runs on the 2nd minute at the 3rd and 4th hour.
|
||||||
#
|
#
|
||||||
def combine(entries)
|
def combine(entries)
|
||||||
entries.map! { |entry| entry.split(/ +/,6 )}
|
entries.map! { |entry| entry.split(/ +/, 6) }
|
||||||
0.upto(4) do |f|
|
0.upto(4) do |f|
|
||||||
(entries.length-1).downto(1) do |i|
|
(entries.length-1).downto(1) do |i|
|
||||||
next if entries[i][f] == '*'
|
next if entries[i][f] == '*'
|
||||||
@ -134,18 +134,25 @@ module Whenever
|
|||||||
def cron_jobs
|
def cron_jobs
|
||||||
return if @jobs.empty?
|
return if @jobs.empty?
|
||||||
|
|
||||||
output = []
|
shortcut_jobs = []
|
||||||
|
regular_jobs = []
|
||||||
|
|
||||||
@jobs.each do |time, jobs|
|
@jobs.each do |time, jobs|
|
||||||
jobs.each do |job|
|
jobs.each do |job|
|
||||||
Whenever::Output::Cron.output(time, job) do |cron|
|
Whenever::Output::Cron.output(time, job) do |cron|
|
||||||
cron << " >> #{job.cron_log} 2>&1" if job.cron_log
|
cron << " >> #{job.cron_log} 2>&1" if job.cron_log
|
||||||
cron << "\n\n"
|
cron << "\n\n"
|
||||||
output << cron
|
|
||||||
|
if cron.starts_with?("@")
|
||||||
|
shortcut_jobs << cron
|
||||||
|
else
|
||||||
|
regular_jobs << cron
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
combine(output).join
|
shortcut_jobs.join + combine(regular_jobs).join
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -134,4 +134,45 @@ class OutputAtTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "Multiple commands output every :reboot" do
|
||||||
|
setup do
|
||||||
|
@output = Whenever.cron \
|
||||||
|
<<-file
|
||||||
|
every :reboot do
|
||||||
|
command "command_1"
|
||||||
|
command "command_2"
|
||||||
|
end
|
||||||
|
file
|
||||||
|
end
|
||||||
|
|
||||||
|
should "output both commands @reboot" do
|
||||||
|
assert_match "@reboot command_1", @output
|
||||||
|
assert_match "@reboot command_2", @output
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "Many different job types output every :day" do
|
||||||
|
setup do
|
||||||
|
@output = Whenever.cron \
|
||||||
|
<<-file
|
||||||
|
set :path, '/your/path'
|
||||||
|
every :day do
|
||||||
|
rake "blah:blah"
|
||||||
|
runner "runner_1"
|
||||||
|
command "command_1"
|
||||||
|
runner "runner_2"
|
||||||
|
command "command_2"
|
||||||
|
end
|
||||||
|
file
|
||||||
|
end
|
||||||
|
|
||||||
|
should "output all of the commands @daily" do
|
||||||
|
assert_match '@daily cd /your/path && RAILS_ENV=production /usr/bin/env rake blah:blah', @output
|
||||||
|
assert_match '@daily /your/path/script/runner -e production "runner_1"', @output
|
||||||
|
assert_match '@daily command_1', @output
|
||||||
|
assert_match '@daily /your/path/script/runner -e production "runner_2"', @output
|
||||||
|
assert_match '@daily command_2', @output
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user