crontinel-rails 0.1.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 +7 -0
- data/CHANGELOG.md +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +82 -0
- data/lib/crontinel/rails/active_job.rb +30 -0
- data/lib/crontinel/rails/engine.rb +44 -0
- data/lib/crontinel/rails/railtie.rb +18 -0
- data/lib/crontinel/rails/sidekiq/server_middleware.rb +33 -0
- data/lib/crontinel/rails/version.rb +7 -0
- data/lib/crontinel-rails.rb +14 -0
- metadata +178 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 2f623c18fd71a3225917bf9c97efb3325a562ddd6d35264e58031e3b29dba8e2
|
|
4
|
+
data.tar.gz: 27624c308a624b11536745fcc299bdc7cffbb3838ae43f1af42e5b043dcde00b
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 4307c84a27cca9079cf2d737a2772679ff45a618ac9cebb5f8dfff5c3c547432710664b83ef29efde75e20df1ddc928fa60e0ff653b9da0ff669628f4cd85e3f
|
|
7
|
+
data.tar.gz: d9b700db533109e35d78f5538971747bc5b645072db40640c48d9273d704b77ecbd1f909827db659b2d8900b08f88ff6c659df0197cb1532aabcc362a6ad48c5
|
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Harun R Rayhan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Crontinel Rails
|
|
2
|
+
|
|
3
|
+
Rails integration for [Crontinel](https://crontinel.com) — open-source monitoring for cron jobs, background workers, and scheduled tasks.
|
|
4
|
+
|
|
5
|
+
Unlike generic uptime tools, Crontinel knows when a job started but crashed silently, when a queue worker stopped processing, or when a cron fired but did nothing.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add to your `Gemfile`:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem "crontinel-rails", "~> 0.1"
|
|
13
|
+
gem "crontinel", "~> 0.1"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
bundle install
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Configuration
|
|
21
|
+
|
|
22
|
+
Create `config/initializers/crontinel.rb`:
|
|
23
|
+
|
|
24
|
+
```ruby
|
|
25
|
+
Crontinel.setup do |config|
|
|
26
|
+
config.api_key = ENV.fetch("CRONTINEL_API_KEY")
|
|
27
|
+
config.endpoint = "https://app.crontinel.com/api/v1" # optional
|
|
28
|
+
end
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Or via environment variables:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
CRONTINEL_API_KEY=your_key_here
|
|
35
|
+
CRONTINEL_ENDPOINT=https://app.crontinel.com/api/v1 # optional
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## ActiveJob Integration
|
|
39
|
+
|
|
40
|
+
Automatically tracks all ActiveJob.perform_later jobs:
|
|
41
|
+
|
|
42
|
+
```ruby
|
|
43
|
+
# Just include the module — it wraps around_perform automatically
|
|
44
|
+
class MyJob < ApplicationJob
|
|
45
|
+
include Crontinel::Rails::ActiveJob
|
|
46
|
+
|
|
47
|
+
def perform(*args)
|
|
48
|
+
# your job work
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Sidekiq Integration
|
|
54
|
+
|
|
55
|
+
Automatically tracks Sidekiq jobs via middleware:
|
|
56
|
+
|
|
57
|
+
```ruby
|
|
58
|
+
# lib/crontinel_rails.rb
|
|
59
|
+
require "crontinel/rails/sidekiq/server_middleware"
|
|
60
|
+
|
|
61
|
+
Sidekiq.configure_server do |config|
|
|
62
|
+
config.server_middleware do |chain|
|
|
63
|
+
chain.add Crontinel::Rails::Sidekiq::ServerMiddleware
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Manual Tracking
|
|
69
|
+
|
|
70
|
+
```ruby
|
|
71
|
+
Crontinel.client.task_started(name: "my-cron-job")
|
|
72
|
+
# do work...
|
|
73
|
+
Crontinel.client.task_finished(name: "my-cron-job", duration_ms: 150)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Supported Rails Versions
|
|
77
|
+
|
|
78
|
+
Rails 6.1+
|
|
79
|
+
|
|
80
|
+
## License
|
|
81
|
+
|
|
82
|
+
MIT © Harun R Rayhan
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Crontinel
|
|
4
|
+
module Rails
|
|
5
|
+
module ActiveJob
|
|
6
|
+
extend ActiveSupport::Concern
|
|
7
|
+
|
|
8
|
+
included do
|
|
9
|
+
around_perform do |job, block|
|
|
10
|
+
client = Crontinel.client rescue nil
|
|
11
|
+
return block.call unless client
|
|
12
|
+
|
|
13
|
+
task_name = "#{job.class.name}-#{job.job_id}"
|
|
14
|
+
client.task_started(name: task_name)
|
|
15
|
+
|
|
16
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
17
|
+
begin
|
|
18
|
+
block.call
|
|
19
|
+
duration_ms = ((Process.clock_gettime(Process::CLOCK_MONOTONIC) - start) * 1000).to_i
|
|
20
|
+
client.task_finished(name: task_name, duration_ms: duration_ms)
|
|
21
|
+
rescue => e
|
|
22
|
+
duration_ms = ((Process.clock_gettime(Process::CLOCK_MONOTONIC) - start) * 1000).to_i
|
|
23
|
+
client.task_failed(name: task_name, error: e.message, duration_ms: duration_ms)
|
|
24
|
+
raise
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Crontinel
|
|
4
|
+
module Rails
|
|
5
|
+
class Engine < ::Rails::Engine
|
|
6
|
+
isolate_namespace Crontinel::Rails
|
|
7
|
+
|
|
8
|
+
config.crontinel = ActiveSupport::OrderedOptions.new
|
|
9
|
+
|
|
10
|
+
config.crontinel.api_key = ENV["CRONTINEL_API_KEY"]
|
|
11
|
+
config.crontinel.endpoint = ENV.fetch("CRONTINEL_ENDPOINT", "https://app.crontinel.com/api/v1")
|
|
12
|
+
config.crontinel.enabled = true
|
|
13
|
+
config.crontinel.log_level = :info
|
|
14
|
+
|
|
15
|
+
initializer "crontinel.configure_defaults" do |app|
|
|
16
|
+
next unless app.config.crontinel.enabled
|
|
17
|
+
|
|
18
|
+
app.config.crontinel.api_key ||= ENV["CRONTINEL_API_KEY"]
|
|
19
|
+
app.config.crontinel.endpoint ||= "https://app.crontinel.com/api/v1"
|
|
20
|
+
|
|
21
|
+
Crontinel.client(
|
|
22
|
+
api_key: app.config.crontinel.api_key,
|
|
23
|
+
endpoint: app.config.crontinel.endpoint
|
|
24
|
+
)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
initializer "crontinel.rails.active_job" do
|
|
28
|
+
ActiveSupport.on_load(:active_job) do
|
|
29
|
+
include Crontinel::Rails::ActiveJob
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
initializer "crontinel.rails.sidekiq" do
|
|
34
|
+
next unless defined?(::Sidekiq) && defined?(::Sidekiq::Middleware)
|
|
35
|
+
|
|
36
|
+
Sidekiq.configure_server do |config|
|
|
37
|
+
config.server_middleware do |chain|
|
|
38
|
+
chain.add Crontinel::Rails::Sidekiq::ServerMiddleware
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Crontinel
|
|
4
|
+
module Rails
|
|
5
|
+
class Railtie < ::Rails::Railtie
|
|
6
|
+
config.crontinel = ActiveSupport::OrderedOptions.new
|
|
7
|
+
|
|
8
|
+
initializer "crontinel.configure" do |app|
|
|
9
|
+
api_key = app.config.crontinel.api_key || ENV["CRONTINEL_API_KEY"]
|
|
10
|
+
Crontinel.configure { |c| c.api_key = api_key } if api_key && defined?(Crontinel)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
rake_tasks do
|
|
14
|
+
require "crontinel/rails/tasks"
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Crontinel
|
|
4
|
+
module Rails
|
|
5
|
+
module Sidekiq
|
|
6
|
+
class ServerMiddleware
|
|
7
|
+
def call(worker, msg, queue)
|
|
8
|
+
client = Crontinel.client rescue nil
|
|
9
|
+
task_name = "#{worker.class.name}-#{msg["jid"]}"
|
|
10
|
+
|
|
11
|
+
if client
|
|
12
|
+
client.task_started(name: task_name)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
16
|
+
begin
|
|
17
|
+
yield
|
|
18
|
+
if client
|
|
19
|
+
duration_ms = ((Process.clock_gettime(Process::CLOCK_MONOTONIC) - start) * 1000).to_i
|
|
20
|
+
client.task_finished(name: task_name, duration_ms: duration_ms)
|
|
21
|
+
end
|
|
22
|
+
rescue => e
|
|
23
|
+
if client
|
|
24
|
+
duration_ms = ((Process.clock_gettime(Process::CLOCK_MONOTONIC) - start) * 1000).to_i
|
|
25
|
+
client.task_failed(name: task_name, error: e.message, duration_ms: duration_ms)
|
|
26
|
+
end
|
|
27
|
+
raise
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "crontinel/rails/version"
|
|
4
|
+
require "crontinel/rails/engine"
|
|
5
|
+
require "crontinel/rails/railtie" if defined?(Rails::Railtie)
|
|
6
|
+
|
|
7
|
+
module Crontinel
|
|
8
|
+
module Rails
|
|
9
|
+
autoload :Railtie, "crontinel/rails/railtie"
|
|
10
|
+
autoload :Middleware, "crontinel/rails/middleware"
|
|
11
|
+
autoload :ActiveJob, "crontinel/rails/active_job"
|
|
12
|
+
autoload :Sidekiq, "crontinel/rails/sidekiq"
|
|
13
|
+
end
|
|
14
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: crontinel-rails
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Harun R Rayhan
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-07-02 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: crontinel
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0.1'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0.1'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: railties
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '6.1'
|
|
34
|
+
- - "<"
|
|
35
|
+
- !ruby/object:Gem::Version
|
|
36
|
+
version: '9.0'
|
|
37
|
+
type: :runtime
|
|
38
|
+
prerelease: false
|
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - ">="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: '6.1'
|
|
44
|
+
- - "<"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '9.0'
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
48
|
+
name: bundler
|
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '2.0'
|
|
54
|
+
type: :development
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '2.0'
|
|
61
|
+
- !ruby/object:Gem::Dependency
|
|
62
|
+
name: rake
|
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - "~>"
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '13.0'
|
|
68
|
+
type: :development
|
|
69
|
+
prerelease: false
|
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - "~>"
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '13.0'
|
|
75
|
+
- !ruby/object:Gem::Dependency
|
|
76
|
+
name: minitest
|
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - "~>"
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '5.0'
|
|
82
|
+
type: :development
|
|
83
|
+
prerelease: false
|
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - "~>"
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '5.0'
|
|
89
|
+
- !ruby/object:Gem::Dependency
|
|
90
|
+
name: rails
|
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - "~>"
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '7.0'
|
|
96
|
+
type: :development
|
|
97
|
+
prerelease: false
|
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - "~>"
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: '7.0'
|
|
103
|
+
- !ruby/object:Gem::Dependency
|
|
104
|
+
name: sidekiq
|
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - "~>"
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '7.0'
|
|
110
|
+
type: :development
|
|
111
|
+
prerelease: false
|
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
113
|
+
requirements:
|
|
114
|
+
- - "~>"
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: '7.0'
|
|
117
|
+
- !ruby/object:Gem::Dependency
|
|
118
|
+
name: rubocop
|
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - "~>"
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: '1.50'
|
|
124
|
+
type: :development
|
|
125
|
+
prerelease: false
|
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
127
|
+
requirements:
|
|
128
|
+
- - "~>"
|
|
129
|
+
- !ruby/object:Gem::Version
|
|
130
|
+
version: '1.50'
|
|
131
|
+
description: |
|
|
132
|
+
Rails integration for Crontinel — open-source monitoring for cron jobs,
|
|
133
|
+
background jobs, and scheduled tasks. Works with ActiveJob, Sidekiq, Rescue,
|
|
134
|
+
and any custom scheduler.
|
|
135
|
+
email:
|
|
136
|
+
- me@harunray.com
|
|
137
|
+
executables: []
|
|
138
|
+
extensions: []
|
|
139
|
+
extra_rdoc_files: []
|
|
140
|
+
files:
|
|
141
|
+
- CHANGELOG.md
|
|
142
|
+
- LICENSE.txt
|
|
143
|
+
- README.md
|
|
144
|
+
- lib/crontinel-rails.rb
|
|
145
|
+
- lib/crontinel/rails/active_job.rb
|
|
146
|
+
- lib/crontinel/rails/engine.rb
|
|
147
|
+
- lib/crontinel/rails/railtie.rb
|
|
148
|
+
- lib/crontinel/rails/sidekiq/server_middleware.rb
|
|
149
|
+
- lib/crontinel/rails/version.rb
|
|
150
|
+
homepage: https://crontinel.com
|
|
151
|
+
licenses:
|
|
152
|
+
- MIT
|
|
153
|
+
metadata:
|
|
154
|
+
homepage_uri: https://crontinel.com
|
|
155
|
+
source_code_uri: https://github.com/crontinel/ruby-on-rails
|
|
156
|
+
changelog_uri: https://github.com/crontinel/ruby-on-rails/blob/main/CHANGELOG.md
|
|
157
|
+
bug_tracker_uri: https://github.com/crontinel/ruby-on-rails/issues
|
|
158
|
+
post_install_message:
|
|
159
|
+
rdoc_options: []
|
|
160
|
+
require_paths:
|
|
161
|
+
- lib
|
|
162
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
163
|
+
requirements:
|
|
164
|
+
- - ">="
|
|
165
|
+
- !ruby/object:Gem::Version
|
|
166
|
+
version: '2.7'
|
|
167
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
|
+
requirements:
|
|
169
|
+
- - ">="
|
|
170
|
+
- !ruby/object:Gem::Version
|
|
171
|
+
version: '0'
|
|
172
|
+
requirements: []
|
|
173
|
+
rubygems_version: 3.0.3.1
|
|
174
|
+
signing_key:
|
|
175
|
+
specification_version: 4
|
|
176
|
+
summary: Crontinel integration for Ruby on Rails — monitor cron jobs and background
|
|
177
|
+
workers
|
|
178
|
+
test_files: []
|