tasks_scheduler 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/scheduled_tasks_controller.rb +1 -1
- data/app/controllers/tasks_scheduler_daemon_controller/_download_log.rb +1 -1
- data/app/models/scheduled_task/log.rb +5 -5
- data/app/models/scheduled_task.rb +3 -3
- data/app/views/scheduled_tasks/log.html.erb +0 -1
- data/app/views/scheduled_tasks/status.html.erb +0 -1
- data/app/views/tasks_scheduler_daemon/index.html.erb +0 -1
- data/config/initializers/menus.rb +1 -1
- data/exe/tasks_scheduler +2 -2
- data/exe/tasks_scheduler_run_task +1 -1
- data/lib/tasks_scheduler/checker/log.rb +1 -1
- data/lib/tasks_scheduler/checker.rb +2 -2
- data/lib/tasks_scheduler/cron_parser_patch.rb +2 -2
- data/lib/tasks_scheduler/cron_scheduling_validator.rb +2 -2
- data/lib/tasks_scheduler/daemon.rb +1 -1
- data/lib/tasks_scheduler/engine.rb +3 -5
- data/lib/tasks_scheduler/version.rb +1 -1
- metadata +4 -6
- data/app/helpers/tasks_scheduler_helper.rb +0 -15
- data/app/views/scheduled_tasks/list.html.erb +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ac4a6905744856629c046c2cbca58290b37c32c1da3f4ef7558927247893ec2
|
4
|
+
data.tar.gz: 1cab19fa0a8be070731efa12f59c2d76cd1a293851b2d132324a60bf1c7d9fa0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5028f905d36a4239fdcd137cc8fde66b2af61da61008871983a4f4bd0923063d904e1ece4f033037bbf29c697a7ce2a1ef44fd83b7f1e78125c590801408377f
|
7
|
+
data.tar.gz: 249dd1417fc904f03c6ae6a81fe17c8a7d6afb941c1ed09924ecfc71e926cc0e679f287d02bf62b7062279059bcc0915f263624320ffdec2deb67a1c01ea3c75
|
@@ -39,7 +39,7 @@ class ScheduledTasksController < ApplicationController
|
|
39
39
|
process_action_link_action do |record|
|
40
40
|
record.update!(next_run: Time.zone.now)
|
41
41
|
record.reload
|
42
|
-
flash[:info] = "Next run adjusted to #{record.next_run}"
|
42
|
+
flash.now[:info] = "Next run adjusted to #{record.next_run}"
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -35,7 +35,7 @@ class TasksSchedulerDaemonController < ApplicationController
|
|
35
35
|
send_file(
|
36
36
|
log.path,
|
37
37
|
filename: "#{request.base_url.parameterize}_tasks-scheduler_checker-log_" \
|
38
|
-
|
38
|
+
"#{Time.zone.now.to_s.parameterize}.log",
|
39
39
|
type: 'text/plain'
|
40
40
|
)
|
41
41
|
end
|
@@ -19,10 +19,10 @@ class ScheduledTask < ActiveRecord::Base
|
|
19
19
|
def log_on_start
|
20
20
|
log_file = log_file(LOG_RUNNING)
|
21
21
|
FileUtils.mkdir_p(File.dirname(log_file))
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
Rails.logger = ActiveSupport::Logger.new(
|
22
|
+
FileUtils.rm_f(log_file)
|
23
|
+
$stdout.reopen(log_file, 'w')
|
24
|
+
$stderr.reopen(log_file, 'w')
|
25
|
+
Rails.logger = ActiveSupport::Logger.new($stdout)
|
26
26
|
end
|
27
27
|
|
28
28
|
def log_on_end(exception)
|
@@ -30,7 +30,7 @@ class ScheduledTask < ActiveRecord::Base
|
|
30
30
|
return unless ::File.exist?(running_log)
|
31
31
|
|
32
32
|
target_log = exception ? log_file(LOG_UNSUCCESSFUL) : log_file(LOG_SUCCESSFUL)
|
33
|
-
|
33
|
+
FileUtils.rm_f(target_log)
|
34
34
|
File.rename(running_log, target_log)
|
35
35
|
end
|
36
36
|
end
|
@@ -22,10 +22,10 @@ class ScheduledTask < ActiveRecord::Base
|
|
22
22
|
|
23
23
|
def timeout
|
24
24
|
@timeout ||= begin
|
25
|
-
r = Integer(ENV
|
25
|
+
r = Integer(ENV.fetch(DEFAULT_TIMEOUT_ENVVAR_NAME, nil))
|
26
26
|
r.positive? ? r.seconds : DEFAULT_TIMEOUT
|
27
|
-
|
28
|
-
|
27
|
+
rescue ArgumentError, TypeError
|
28
|
+
DEFAULT_TIMEOUT
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'eac_rails_utils/patches/application'
|
4
4
|
|
5
|
-
|
5
|
+
Rails.application.root_menu.group(:admin).group(:tasks_scheduler).within do |g|
|
6
6
|
g.action :tasks_scheduler_daemon
|
7
7
|
g.action :scheduled_tasks
|
8
8
|
g.action :status_scheduled_tasks
|
data/exe/tasks_scheduler
CHANGED
@@ -16,8 +16,8 @@ rails_root = find_rails_root
|
|
16
16
|
dir = File.expand_path('tmp/pids', rails_root)
|
17
17
|
FileUtils.mkdir_p(dir)
|
18
18
|
Daemons.run_proc 'tasks_scheduler', dir_mode: :normal, dir: dir do
|
19
|
-
|
19
|
+
Dir.chdir(rails_root) do
|
20
20
|
require File.join(rails_root, 'config', 'environment')
|
21
|
-
|
21
|
+
TasksScheduler::Checker.instance.run
|
22
22
|
end
|
23
23
|
end
|
@@ -16,7 +16,7 @@ module TasksScheduler
|
|
16
16
|
Signal.trap('TERM') { running = false }
|
17
17
|
while running
|
18
18
|
Rails.logger.info('Checking all tasks...')
|
19
|
-
::ScheduledTask.
|
19
|
+
::ScheduledTask.order(next_run: :asc).each(&:check)
|
20
20
|
Rails.logger.info("All tasks checked. Sleeping for #{CHECK_INTERVAL} second(s)...")
|
21
21
|
sleep(CHECK_INTERVAL)
|
22
22
|
end
|
@@ -31,7 +31,7 @@ module TasksScheduler
|
|
31
31
|
end
|
32
32
|
|
33
33
|
LOGS_KEYS.each do |log_key|
|
34
|
-
class_eval <<CODE, __FILE__, __LINE__ + 1
|
34
|
+
class_eval <<CODE, __FILE__, __LINE__ + 1 # rubocop:disable Style/DocumentDynamicEvalDefinition
|
35
35
|
def #{log_key}_log
|
36
36
|
@#{log_key}_log ||= ::TasksScheduler::Checker::Log.new('#{log_key}')
|
37
37
|
end
|
@@ -26,6 +26,6 @@ module TasksScheduler
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
unless
|
30
|
-
|
29
|
+
unless CronParser.included_modules.include?(TasksScheduler::CronParserPatch)
|
30
|
+
CronParser.include(TasksScheduler::CronParserPatch)
|
31
31
|
end
|
@@ -5,8 +5,8 @@ module TasksScheduler
|
|
5
5
|
def validate_each(record, attribute, value)
|
6
6
|
return if value_valid?(value)
|
7
7
|
|
8
|
-
record.errors
|
9
|
-
I18n.t(:cron_scheduling_validator_error_message))
|
8
|
+
record.errors.add(attribute, (options[:message] ||
|
9
|
+
I18n.t(:cron_scheduling_validator_error_message)))
|
10
10
|
end
|
11
11
|
|
12
12
|
private
|
@@ -11,7 +11,7 @@ module TasksScheduler
|
|
11
11
|
raise "Action not allowed: #{action} (Allowed: #{ACTIONS})" unless ACTIONS.include?(action)
|
12
12
|
|
13
13
|
::TasksScheduler::AppGem.instance.bundle('exec', 'tasks_scheduler', action)
|
14
|
-
|
14
|
+
.envvar(::TasksScheduler::Checker::LOG_ON_FILE_ENV_KEY, '1')
|
15
15
|
end
|
16
16
|
|
17
17
|
def execute(action)
|
@@ -1,13 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'eac_active_scaffold'
|
4
|
+
require 'eac_rails_utils/engine'
|
5
|
+
require 'eac_rails_utils/engine_helper'
|
4
6
|
|
5
7
|
module TasksScheduler
|
6
8
|
class Engine < ::Rails::Engine
|
7
|
-
|
8
|
-
config.paths['db/migrate'].expanded.each do |expanded_path|
|
9
|
-
app.config.paths['db/migrate'] << expanded_path
|
10
|
-
end
|
11
|
-
end
|
9
|
+
include ::EacRailsUtils::EngineHelper
|
12
10
|
end
|
13
11
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tasks_scheduler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo H. Bogoni
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avm-eac_ruby_base1
|
@@ -144,14 +144,14 @@ dependencies:
|
|
144
144
|
requirements:
|
145
145
|
- - "~>"
|
146
146
|
- !ruby/object:Gem::Version
|
147
|
-
version: 0.
|
147
|
+
version: 0.8.0
|
148
148
|
type: :development
|
149
149
|
prerelease: false
|
150
150
|
version_requirements: !ruby/object:Gem::Requirement
|
151
151
|
requirements:
|
152
152
|
- - "~>"
|
153
153
|
- !ruby/object:Gem::Version
|
154
|
-
version: 0.
|
154
|
+
version: 0.8.0
|
155
155
|
description:
|
156
156
|
email:
|
157
157
|
- eduardobogoni@gmail.com
|
@@ -173,13 +173,11 @@ files:
|
|
173
173
|
- app/controllers/tasks_scheduler_daemon_controller.rb
|
174
174
|
- app/controllers/tasks_scheduler_daemon_controller/_download_log.rb
|
175
175
|
- app/helpers/scheduled_tasks_helper.rb
|
176
|
-
- app/helpers/tasks_scheduler_helper.rb
|
177
176
|
- app/models/scheduled_task.rb
|
178
177
|
- app/models/scheduled_task/checker.rb
|
179
178
|
- app/models/scheduled_task/log.rb
|
180
179
|
- app/models/scheduled_task/runner.rb
|
181
180
|
- app/models/scheduled_task/status.rb
|
182
|
-
- app/views/scheduled_tasks/list.html.erb
|
183
181
|
- app/views/scheduled_tasks/log.html.erb
|
184
182
|
- app/views/scheduled_tasks/status.html.erb
|
185
183
|
- app/views/scheduled_tasks/status_content.html.erb
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module TasksSchedulerHelper
|
4
|
-
def tasks_scheduler_navbar
|
5
|
-
tag.navbar do
|
6
|
-
safe_join(tasks_scheduler_navbar_entries.map { |label, path| link_to label, path }, ' | ')
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def tasks_scheduler_navbar_entries
|
11
|
-
::Rails.application.root_menu.sub(:admin).sub(:tasks_scheduler).children
|
12
|
-
.map { |child| [child.label, child.view_path(self)] }
|
13
|
-
.to_h
|
14
|
-
end
|
15
|
-
end
|