schked 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +21 -0
- data/README.md +140 -0
- data/exe/schked +10 -1
- data/lib/schked/config.rb +7 -2
- data/lib/schked/railtie.rb +4 -1
- data/lib/schked/version.rb +1 -1
- metadata +26 -51
- data/Rakefile +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8543c91732ed3147359b2b6c5c8ebef8ddb2f467766a8c143072ac403341647
|
4
|
+
data.tar.gz: d85da0ba7c7f001d9682c9423a59bb35a8ff4c3581583fbf1ed31cc11650c866
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e87e77de1530b23d680660806edafba03eb191c72da03d8b37b2b0a3845916ce700924e9d51806a20fbba58d8c1c9403e2a9c8d7c33103ab0eb4ceeaa76cdd1
|
7
|
+
data.tar.gz: 4408c7dfb6b03b73018d2d80cd005e52b6ddfc28635fd6eca972c670f17add271e2e89501452220dec116d48c529cb4d5f43761cc7416ddd6a247a3444ee713d
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Michael Merkushin
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/schked.svg)](https://badge.fury.io/rb/schked)
|
2
|
+
[![Build Status](https://travis-ci.org/bibendi/schked.svg?branch=master)](https://travis-ci.org/bibendi/schked)
|
3
|
+
|
4
|
+
# Schked
|
5
|
+
|
6
|
+
Framework agnostic [Rufus-scheduler](https://github.com/jmettraux/rufus-scheduler) wrapper to run recurring jobs.
|
7
|
+
|
8
|
+
<a href="https://evilmartians.com/?utm_source=schked">
|
9
|
+
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"></a>
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem "schked"
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
```sh
|
22
|
+
bundle
|
23
|
+
```
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
```sh
|
28
|
+
gem install schked
|
29
|
+
```
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
### Ruby on Rails
|
34
|
+
|
35
|
+
.schked
|
36
|
+
|
37
|
+
```
|
38
|
+
--require config/environment.rb
|
39
|
+
```
|
40
|
+
|
41
|
+
config/schedule.rb
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
cron "*/30 * * * *", as: "CleanOrphanAttachmentsJob" do
|
45
|
+
CleanOrphanAttachmentsJob.perform_later
|
46
|
+
end
|
47
|
+
```
|
48
|
+
|
49
|
+
If you have a Rails engine with own schedule:
|
50
|
+
|
51
|
+
engine-path/lib/foo/engine.rb
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
module Foo
|
55
|
+
class Engine < ::Rails::Engine
|
56
|
+
initializer "foo" do |app|
|
57
|
+
Schked.config.paths << root.join("config", "schedule.rb")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
63
|
+
And run Schked:
|
64
|
+
|
65
|
+
```sh
|
66
|
+
bundle exec schked start
|
67
|
+
```
|
68
|
+
|
69
|
+
To show schedule:
|
70
|
+
|
71
|
+
```sh
|
72
|
+
bundle exec schked show
|
73
|
+
```
|
74
|
+
|
75
|
+
### Callbacks
|
76
|
+
|
77
|
+
Also, you can define callbacks for errors handling:
|
78
|
+
|
79
|
+
config/initializers/schked.rb
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
Schked.config.register_callback(:on_error) do |job, error|
|
83
|
+
Raven.capture_exception(error) if defined?(Raven)
|
84
|
+
end
|
85
|
+
```
|
86
|
+
|
87
|
+
There are `:before_start` and `:after_finish` callbacks as well.
|
88
|
+
|
89
|
+
### Logging
|
90
|
+
|
91
|
+
By default Schked writes logs into stdout. In Rails environment Schked is using application logger. You can change it like this:
|
92
|
+
|
93
|
+
config/initializers/schked.rb
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
Schked.config.logger = Logger.new(Rails.root.join("log", "schked.log"))
|
97
|
+
```
|
98
|
+
|
99
|
+
### Monitoring
|
100
|
+
|
101
|
+
[Yabeda::Schked](https://github.com/yabeda-rb/yabeda-schked) - built-in metrics for monitoring Schked recurring jobs out of the box! Part of the [yabeda](https://github.com/yabeda-rb/yabeda) suite.
|
102
|
+
|
103
|
+
### Testing
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
describe Schked do
|
107
|
+
let(:worker) { described_class.worker.tap(&:pause) }
|
108
|
+
|
109
|
+
around do |ex|
|
110
|
+
Time.use_zone("UTC") { Timecop.travel(start_time, &ex) }
|
111
|
+
end
|
112
|
+
|
113
|
+
describe "CleanOrphanAttachmentsJob" do
|
114
|
+
let(:start_time) { Time.zone.local(2008, 9, 1, 10, 42, 21) }
|
115
|
+
let(:job) { worker.job("CleanOrphanAttachmentsJob") }
|
116
|
+
|
117
|
+
specify do
|
118
|
+
expect(job.next_time.to_local_time)
|
119
|
+
.to eq Time.zone.local(2008, 9, 1, 11, 0, 0)
|
120
|
+
end
|
121
|
+
|
122
|
+
it "enqueues job" do
|
123
|
+
expect { job.call(false) }
|
124
|
+
.to have_enqueued_job(CleanOrphanAttachmentsJob)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
```
|
129
|
+
|
130
|
+
## Contributing
|
131
|
+
|
132
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/bibendi/schked. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
133
|
+
|
134
|
+
## License
|
135
|
+
|
136
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
137
|
+
|
138
|
+
## Code of Conduct
|
139
|
+
|
140
|
+
Everyone interacting in the Schked project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/schked/blob/master/CODE_OF_CONDUCT.md).
|
data/exe/schked
CHANGED
@@ -4,4 +4,13 @@
|
|
4
4
|
require "bundler/setup"
|
5
5
|
require "schked/cli"
|
6
6
|
|
7
|
-
|
7
|
+
# rubocop:disable Lint/RescueException
|
8
|
+
begin
|
9
|
+
Schked::CLI.start(ARGV)
|
10
|
+
rescue Exception => e
|
11
|
+
warn "Schked exited with error"
|
12
|
+
warn(e.message) if e.respond_to?(:message)
|
13
|
+
warn(e.backtrace.join("\n")) if e.respond_to?(:backtrace) && e.backtrace.respond_to?(:join)
|
14
|
+
exit 1
|
15
|
+
end
|
16
|
+
# rubocop:enable Lint/RescueException
|
data/lib/schked/config.rb
CHANGED
@@ -4,7 +4,8 @@ require "logger"
|
|
4
4
|
|
5
5
|
module Schked
|
6
6
|
class Config
|
7
|
-
attr_writer :logger
|
7
|
+
attr_writer :logger,
|
8
|
+
:do_not_load_root_schedule
|
8
9
|
|
9
10
|
def paths
|
10
11
|
@paths ||= []
|
@@ -15,7 +16,11 @@ module Schked
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def logger
|
18
|
-
@logger ||= Logger.new(
|
19
|
+
@logger ||= Logger.new($stdout).tap { |l| l.level = Logger::INFO }
|
20
|
+
end
|
21
|
+
|
22
|
+
def do_not_load_root_schedule?
|
23
|
+
!!@do_not_load_root_schedule
|
19
24
|
end
|
20
25
|
|
21
26
|
def register_callback(name, &block)
|
data/lib/schked/railtie.rb
CHANGED
@@ -6,7 +6,10 @@ module Schked
|
|
6
6
|
class Railtie < Rails::Railtie
|
7
7
|
class PathsConfig
|
8
8
|
def self.call(app)
|
9
|
-
if
|
9
|
+
return if Schked.config.do_not_load_root_schedule?
|
10
|
+
|
11
|
+
root_schedule = app.root.join("config", "schedule.rb")
|
12
|
+
if root_schedule.exist?
|
10
13
|
path = root_schedule.to_s
|
11
14
|
Schked.config.paths << path unless Schked.config.paths.include?(path)
|
12
15
|
end
|
data/lib/schked/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schked
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
7
|
+
- Misha Merkushin
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rufus-scheduler
|
@@ -72,28 +72,28 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1.
|
75
|
+
version: '1.3'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
82
|
+
version: '1.3'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: pry-byebug
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '3.
|
89
|
+
version: '3.9'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '3.
|
96
|
+
version: '3.9'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rake
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,64 +114,38 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '3.
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '3.0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: rubocop
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0.60'
|
117
|
+
version: '3.9'
|
132
118
|
type: :development
|
133
119
|
prerelease: false
|
134
120
|
version_requirements: !ruby/object:Gem::Requirement
|
135
121
|
requirements:
|
136
122
|
- - "~>"
|
137
123
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: rubocop-rspec
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - ">="
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '0'
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - ">="
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '0'
|
124
|
+
version: '3.9'
|
153
125
|
- !ruby/object:Gem::Dependency
|
154
126
|
name: standard
|
155
127
|
requirement: !ruby/object:Gem::Requirement
|
156
128
|
requirements:
|
157
129
|
- - "~>"
|
158
130
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.
|
131
|
+
version: '0.4'
|
160
132
|
type: :development
|
161
133
|
prerelease: false
|
162
134
|
version_requirements: !ruby/object:Gem::Requirement
|
163
135
|
requirements:
|
164
136
|
- - "~>"
|
165
137
|
- !ruby/object:Gem::Version
|
166
|
-
version: 0.
|
138
|
+
version: '0.4'
|
167
139
|
description: Rufus-scheduler wrapper to run recurring jobs
|
168
|
-
email:
|
140
|
+
email:
|
141
|
+
- merkushin.m.s@gmail.com
|
169
142
|
executables:
|
170
143
|
- schked
|
171
144
|
extensions: []
|
172
145
|
extra_rdoc_files: []
|
173
146
|
files:
|
174
|
-
-
|
147
|
+
- LICENSE.txt
|
148
|
+
- README.md
|
175
149
|
- exe/schked
|
176
150
|
- lib/schked.rb
|
177
151
|
- lib/schked/cli.rb
|
@@ -179,27 +153,28 @@ files:
|
|
179
153
|
- lib/schked/railtie.rb
|
180
154
|
- lib/schked/version.rb
|
181
155
|
- lib/schked/worker.rb
|
182
|
-
homepage:
|
183
|
-
licenses:
|
184
|
-
|
185
|
-
|
156
|
+
homepage: https://github.com/bibendi/schked
|
157
|
+
licenses:
|
158
|
+
- MIT
|
159
|
+
metadata:
|
160
|
+
allowed_push_host: https://rubygems.org
|
161
|
+
post_install_message:
|
186
162
|
rdoc_options: []
|
187
163
|
require_paths:
|
188
164
|
- lib
|
189
165
|
required_ruby_version: !ruby/object:Gem::Requirement
|
190
166
|
requirements:
|
191
|
-
- - "
|
167
|
+
- - ">"
|
192
168
|
- !ruby/object:Gem::Version
|
193
|
-
version: '
|
169
|
+
version: '2.5'
|
194
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
195
171
|
requirements:
|
196
172
|
- - ">="
|
197
173
|
- !ruby/object:Gem::Version
|
198
174
|
version: '0'
|
199
175
|
requirements: []
|
200
|
-
|
201
|
-
|
202
|
-
signing_key:
|
176
|
+
rubygems_version: 3.2.32
|
177
|
+
signing_key:
|
203
178
|
specification_version: 4
|
204
179
|
summary: Ruby Scheduler
|
205
180
|
test_files: []
|
data/Rakefile
DELETED