job_harbor 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +10 -1
- data/app/controllers/job_harbor/application_controller.rb +1 -4
- data/app/controllers/job_harbor/recurring_tasks_controller.rb +1 -0
- data/app/models/job_harbor/recurring_task_queue.rb +31 -0
- data/app/views/job_harbor/recurring_tasks/index.html.erb +1 -1
- data/app/views/job_harbor/recurring_tasks/show.html.erb +1 -1
- data/app/views/layouts/job_harbor/application.html.erb +6 -4
- data/lib/generators/job_harbor/install/install_generator.rb +22 -0
- data/lib/generators/job_harbor/install/templates/job_harbor.rb.tt +39 -0
- data/lib/job_harbor/version.rb +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 303b8b53351a0bd2896009dda7f389fe5e765605e2c78886b87f6a27f01b2f3c
|
|
4
|
+
data.tar.gz: 2fd071bf4835ad91ebc52073e336a3cbeddd7f5e0866aadcd0dede99093252a9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 89a51954fd2a53480352be425d426bae9227cd8646b74e61061f4165526ff1401604f802f1ac7a06d09a46c390e3ec6de7e3e96f46cd9ce4cb52c20ef76f01ab
|
|
7
|
+
data.tar.gz: 59e555d78e06142e67e941c2494a932a567dfa68fd7e6fdb8885b74c4aa0851bf3026fa9fc1a1d4da9df28ce3c21856b26c2d7a38add48b134fb87a066d2e2ed
|
data/README.md
CHANGED
|
@@ -75,6 +75,15 @@ Then run:
|
|
|
75
75
|
bundle install
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
+
Generate the initializer:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
bin/rails generate job_harbor:install
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
This creates `config/initializers/job_harbor.rb` with every setting commented out at its
|
|
85
|
+
default, so installing it changes nothing until you uncomment a line.
|
|
86
|
+
|
|
78
87
|
## Mounting
|
|
79
88
|
|
|
80
89
|
Mount the engine in your routes:
|
|
@@ -96,7 +105,7 @@ end
|
|
|
96
105
|
|
|
97
106
|
## Configuration
|
|
98
107
|
|
|
99
|
-
|
|
108
|
+
Settings live in `config/initializers/job_harbor.rb`, created by `bin/rails generate job_harbor:install`:
|
|
100
109
|
|
|
101
110
|
```ruby
|
|
102
111
|
JobHarbor.configure do |config|
|
|
@@ -47,10 +47,7 @@ module JobHarbor
|
|
|
47
47
|
|
|
48
48
|
def return_to_app_path
|
|
49
49
|
configured = sq_config.return_to_app_path
|
|
50
|
-
|
|
51
|
-
return instance_exec(&configured) if configured.respond_to?(:call)
|
|
52
|
-
|
|
53
|
-
main_app.root_path
|
|
50
|
+
(configured.respond_to?(:call) ? instance_exec(&configured) : configured).presence
|
|
54
51
|
rescue
|
|
55
52
|
"/"
|
|
56
53
|
end
|
|
@@ -15,6 +15,7 @@ module JobHarbor
|
|
|
15
15
|
def show
|
|
16
16
|
executions = SolidQueue::RecurringExecution.where(task_key: @task.key)
|
|
17
17
|
@task_arguments = RecurringTaskArguments.new(@task)
|
|
18
|
+
@task_queue = RecurringTaskQueue.new(@task)
|
|
18
19
|
@executions_count = executions.count
|
|
19
20
|
@last_run_at = executions.maximum(:run_at)
|
|
20
21
|
@recent_executions = executions.order(run_at: :desc).limit(RECENT_EXECUTIONS_LIMIT)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module JobHarbor
|
|
4
|
+
class RecurringTaskQueue
|
|
5
|
+
def initialize(task)
|
|
6
|
+
@task = task
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# SQ stores queue_name only when recurring.yml sets one; otherwise the job class's queue_as decides.
|
|
10
|
+
def name
|
|
11
|
+
@task.queue_name.presence || job_class_queue_name
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
# A queue_as block may read arguments we don't pass, so a raising block means we can't know the queue.
|
|
17
|
+
def job_class_queue_name
|
|
18
|
+
job_class&.new&.queue_name
|
|
19
|
+
rescue StandardError
|
|
20
|
+
nil
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Mirrors SQ's RecurringTask#job_class: a command task runs on SQ's default job class.
|
|
24
|
+
def job_class
|
|
25
|
+
return SolidQueue::RecurringTask.default_job_class if @task.class_name.blank?
|
|
26
|
+
|
|
27
|
+
klass = @task.class_name.safe_constantize
|
|
28
|
+
klass if klass.is_a?(Class) && klass < ActiveJob::Base
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
<td><%= link_to task.key, recurring_task_path(task), class: "link font-medium" %></td>
|
|
24
24
|
<td><code class="text-sm font-mono"><%= task.class_name %></code></td>
|
|
25
25
|
<td class="text-sm"><%= task.schedule %></td>
|
|
26
|
-
<td class="text-sm"><%= task.
|
|
26
|
+
<td class="text-sm"><%= JobHarbor::RecurringTaskQueue.new(task).name || "—" %></td>
|
|
27
27
|
<td>
|
|
28
28
|
<%= button_to "Run Now", enqueue_now_recurring_task_path(task), method: :post, class: "btn btn-secondary btn-xs" %>
|
|
29
29
|
</td>
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
<%= render JobHarbor::InfoLineComponent.new(label: "Schedule", value: @task.schedule) %>
|
|
21
21
|
|
|
22
|
-
<%= render JobHarbor::InfoLineComponent.new(label: "Queue", value: @
|
|
22
|
+
<%= render JobHarbor::InfoLineComponent.new(label: "Queue", value: @task_queue.name || "—") %>
|
|
23
23
|
|
|
24
24
|
<% if @task_arguments.present? %>
|
|
25
25
|
<div class="mt-3">
|
|
@@ -58,10 +58,12 @@
|
|
|
58
58
|
<%= render JobHarbor::RefreshSelectorComponent.new %>
|
|
59
59
|
<% end %>
|
|
60
60
|
<%= render JobHarbor::ThemeToggleComponent.new %>
|
|
61
|
-
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
<% if (back_path = return_to_app_path) %>
|
|
62
|
+
<a href="<%= back_path %>" class="btn btn-outline btn-sm" title="<%= return_to_app_label %>">
|
|
63
|
+
<svg class="w-3.5 h-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M19 12H5M12 19l-7-7 7-7"/></svg>
|
|
64
|
+
<span class="hidden sm:inline"><%= return_to_app_label %></span>
|
|
65
|
+
</a>
|
|
66
|
+
<% end %>
|
|
65
67
|
</div>
|
|
66
68
|
</nav>
|
|
67
69
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require "rails/generators"
|
|
2
|
+
|
|
3
|
+
module JobHarbor
|
|
4
|
+
module Generators
|
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
|
7
|
+
|
|
8
|
+
desc "Creates a JobHarbor initializer at config/initializers/job_harbor.rb with every setting at its default."
|
|
9
|
+
|
|
10
|
+
def copy_initializer
|
|
11
|
+
template "job_harbor.rb", "config/initializers/job_harbor.rb"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def show_next_steps
|
|
15
|
+
say "\nMount the dashboard in config/routes.rb:"
|
|
16
|
+
say %( mount JobHarbor::Engine, at: "/job_harbor")
|
|
17
|
+
say "\nThen set config.authorize_with in config/initializers/job_harbor.rb."
|
|
18
|
+
say "Until you do, the dashboard denies every request outside development and test.\n"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# JobHarbor configuration. Every setting below is shown at its default; uncomment one to change it.
|
|
2
|
+
# See https://github.com/esparkman/job_harbor#configuration for details.
|
|
3
|
+
JobHarbor.configure do |config|
|
|
4
|
+
# Authorization: a lambda run in the dashboard controller (instance_exec), so it can call your
|
|
5
|
+
# app's helpers such as current_user. Return a truthy value to allow the request.
|
|
6
|
+
# Unset, the dashboard is open in development and test and denied in every other environment.
|
|
7
|
+
# config.authorize_with = nil
|
|
8
|
+
# For example: config.authorize_with = -> { current_user&.admin? }
|
|
9
|
+
|
|
10
|
+
# Theme: :dark or :light
|
|
11
|
+
# config.theme = :dark
|
|
12
|
+
|
|
13
|
+
# Jobs per page
|
|
14
|
+
# config.jobs_per_page = 25
|
|
15
|
+
|
|
16
|
+
# Auto-refresh polling interval in seconds.
|
|
17
|
+
# The selector offers Off, 15, 30, 60 and 300; any other value is added as its own option.
|
|
18
|
+
# config.poll_interval = 30
|
|
19
|
+
|
|
20
|
+
# Features
|
|
21
|
+
# config.enable_recurring_tasks = true
|
|
22
|
+
# config.enable_real_time_updates = true # false removes auto-refresh entirely
|
|
23
|
+
# config.enable_failure_stats = true
|
|
24
|
+
# config.enable_charts = true
|
|
25
|
+
|
|
26
|
+
# Default chart time range
|
|
27
|
+
# config.default_chart_range = "24h"
|
|
28
|
+
|
|
29
|
+
# "Back to App" link in the navbar, hidden until set. Takes a path or a proc run in the dashboard
|
|
30
|
+
# controller; a blank result hides the link.
|
|
31
|
+
# config.return_to_app_path = nil
|
|
32
|
+
# For example: config.return_to_app_path = -> { main_app.root_path }
|
|
33
|
+
# config.return_to_app_label = "Back to App"
|
|
34
|
+
|
|
35
|
+
# Sensitive values in job arguments, payloads and recurring task arguments.
|
|
36
|
+
# nil uses your app's config.filter_parameters; an Array of Strings, Symbols, Regexps and Procs
|
|
37
|
+
# replaces that list; false shows raw values and brings back searching by argument.
|
|
38
|
+
# config.filter_parameters = nil
|
|
39
|
+
end
|
data/lib/job_harbor/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: job_harbor
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Evan Sparkman
|
|
@@ -111,6 +111,7 @@ files:
|
|
|
111
111
|
- app/models/job_harbor/processes.rb
|
|
112
112
|
- app/models/job_harbor/queue_stats.rb
|
|
113
113
|
- app/models/job_harbor/recurring_task_arguments.rb
|
|
114
|
+
- app/models/job_harbor/recurring_task_queue.rb
|
|
114
115
|
- app/models/job_harbor/sensitive_value_filter.rb
|
|
115
116
|
- app/views/job_harbor/dashboard/index.html.erb
|
|
116
117
|
- app/views/job_harbor/jobs/index.html.erb
|
|
@@ -123,6 +124,8 @@ files:
|
|
|
123
124
|
- app/views/job_harbor/workers/index.html.erb
|
|
124
125
|
- app/views/layouts/job_harbor/application.html.erb
|
|
125
126
|
- config/routes.rb
|
|
127
|
+
- lib/generators/job_harbor/install/install_generator.rb
|
|
128
|
+
- lib/generators/job_harbor/install/templates/job_harbor.rb.tt
|
|
126
129
|
- lib/job_harbor.rb
|
|
127
130
|
- lib/job_harbor/configuration.rb
|
|
128
131
|
- lib/job_harbor/engine.rb
|