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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b913be2e2291cc27208e02af8b31c07d85070b73037c1eea24c1f91f45e63a9
4
- data.tar.gz: 2fe374924c6751c1ef33c6c727dea2dfe83dccfd521de2e5a24783691db5d7a4
3
+ metadata.gz: 8ac4a6905744856629c046c2cbca58290b37c32c1da3f4ef7558927247893ec2
4
+ data.tar.gz: 1cab19fa0a8be070731efa12f59c2d76cd1a293851b2d132324a60bf1c7d9fa0
5
5
  SHA512:
6
- metadata.gz: 57ddcdd38e84cabcc98419ce1bf8904a0854c43c6d03f3b0edf1c4542dacb52ac0d3367ebd4c714025900a01184d05215cdc23c7cb02683085cfb5dd7a0cce4b
7
- data.tar.gz: 9d151d67c6a38040bde4a78f4021adc646890260f56c8f4172a88397b9fa566c624386eb499df80f4e65489d4beffd19666381fae6549124d0601b549359b065
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
- "#{Time.zone.now.to_s.parameterize}.log",
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
- File.unlink(log_file) if File.exist?(log_file)
23
- STDOUT.reopen(log_file, 'w')
24
- STDERR.reopen(log_file, 'w')
25
- Rails.logger = ActiveSupport::Logger.new(STDOUT)
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
- File.unlink(target_log) if File.exist?(target_log)
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[DEFAULT_TIMEOUT_ENVVAR_NAME])
25
+ r = Integer(ENV.fetch(DEFAULT_TIMEOUT_ENVVAR_NAME, nil))
26
26
  r.positive? ? r.seconds : DEFAULT_TIMEOUT
27
- rescue ArgumentError, TypeError
28
- DEFAULT_TIMEOUT
27
+ rescue ArgumentError, TypeError
28
+ DEFAULT_TIMEOUT
29
29
  end
30
30
  end
31
31
  end
@@ -1,4 +1,3 @@
1
- <%= tasks_scheduler_navbar %>
2
1
  <p>Log file: <%= @log_file %></p>
3
2
  <% if File.exist?(@log_file) %>
4
3
  <p>Content: </p>
@@ -1,4 +1,3 @@
1
- <%= tasks_scheduler_navbar %>
2
1
  <h2><%= I18n.t(:tasks_scheduler_status) %></h2>
3
2
  <div id="TaskScheduler_Status_Status">
4
3
  </div>
@@ -1,4 +1,3 @@
1
- <%= tasks_scheduler_navbar %>
2
1
  <h2><%= I18n.t(:tasks_scheduler_daemon) %></h2>
3
2
  <%= render partial: 'daemon', locals: {status_label: 'Status:'} %>
4
3
  <%= render partial: 'logs' %>
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'eac_rails_utils/patches/application'
4
4
 
5
- ::Rails.application.root_menu.group(:admin).group(:tasks_scheduler).within do |g|
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
- ::Dir.chdir(rails_root) do
19
+ Dir.chdir(rails_root) do
20
20
  require File.join(rails_root, 'config', 'environment')
21
- ::TasksScheduler::Checker.instance.run
21
+ TasksScheduler::Checker.instance.run
22
22
  end
23
23
  end
@@ -13,4 +13,4 @@ end
13
13
 
14
14
  rails_root = find_rails_root
15
15
  require File.join(rails_root, 'config', 'environment')
16
- ::ScheduledTask.find(ARGV[0].to_i).run
16
+ ScheduledTask.find(ARGV[0].to_i).run
@@ -7,7 +7,7 @@ module TasksScheduler
7
7
  class Log
8
8
  class << self
9
9
  def logs_directory
10
- @logs_directory ||= ::Rails.root.join('log', 'tasks_scheduler', 'checker')
10
+ @logs_directory ||= ::Rails.root.join('log/tasks_scheduler/checker')
11
11
  end
12
12
  end
13
13
 
@@ -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.all.order(next_run: :asc).each(&:check)
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 ::CronParser.included_modules.include?(::TasksScheduler::CronParserPatch)
30
- ::CronParser.include(::TasksScheduler::CronParserPatch)
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[attribute] << (options[:message] ||
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
- .envvar(::TasksScheduler::Checker::LOG_ON_FILE_ENV_KEY, '1')
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
- initializer :append_migrations do |app|
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TasksScheduler
4
- VERSION = '0.7.0'
4
+ VERSION = '0.8.0'
5
5
  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.7.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-09-18 00:00:00.000000000 Z
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.7.2
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.7.2
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
@@ -1,2 +0,0 @@
1
- <%= tasks_scheduler_navbar %>
2
- <%= render :super %>