schked 0.3.2 → 0.3.3
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 +5 -3
- data/lib/schked/config.rb +1 -1
- data/lib/schked/version.rb +1 -1
- metadata +17 -13
- 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: d63d5c90dcb6ba4e576ebd9ac7f07d8f8169473836bd38d656a69d550e08c304
|
4
|
+
data.tar.gz: b33124e9bd3125d1cf93d418c165e275d6ab89d727938313fdb7b492cd35861e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83dd4020439f63a22f1cf3226b538a408adb5b444df1bb6e9def70d07f56d18c6084dfc58d5d3c7f226e3edeb61192d825ff556a5f56c8996195331bfee82670
|
7
|
+
data.tar.gz: 002453deb8896a3c248148cd904fac48910118c3cee0b1e2485ad0b98db39ea36550d623501e4eaa51d52c3f3150ada08915fe385ea99509f34bc7f4a7d98928
|
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 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,11 +4,13 @@
|
|
4
4
|
require "bundler/setup"
|
5
5
|
require "schked/cli"
|
6
6
|
|
7
|
+
# rubocop:disable Lint/RescueException
|
7
8
|
begin
|
8
9
|
Schked::CLI.start(ARGV)
|
9
10
|
rescue Exception => e
|
10
|
-
|
11
|
-
|
12
|
-
|
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)
|
13
14
|
exit 1
|
14
15
|
end
|
16
|
+
# rubocop:enable Lint/RescueException
|
data/lib/schked/config.rb
CHANGED
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.3.
|
4
|
+
version: 0.3.3
|
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: 2021-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rufus-scheduler
|
@@ -137,13 +137,15 @@ dependencies:
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0.4'
|
139
139
|
description: Rufus-scheduler wrapper to run recurring jobs
|
140
|
-
email:
|
140
|
+
email:
|
141
|
+
- merkushin.m.s@gmail.com
|
141
142
|
executables:
|
142
143
|
- schked
|
143
144
|
extensions: []
|
144
145
|
extra_rdoc_files: []
|
145
146
|
files:
|
146
|
-
-
|
147
|
+
- LICENSE.txt
|
148
|
+
- README.md
|
147
149
|
- exe/schked
|
148
150
|
- lib/schked.rb
|
149
151
|
- lib/schked/cli.rb
|
@@ -151,18 +153,20 @@ files:
|
|
151
153
|
- lib/schked/railtie.rb
|
152
154
|
- lib/schked/version.rb
|
153
155
|
- lib/schked/worker.rb
|
154
|
-
homepage:
|
155
|
-
licenses:
|
156
|
-
|
157
|
-
|
156
|
+
homepage: https://github.com/bibendi/schked
|
157
|
+
licenses:
|
158
|
+
- MIT
|
159
|
+
metadata:
|
160
|
+
allowed_push_host: https://rubygems.org
|
161
|
+
post_install_message:
|
158
162
|
rdoc_options: []
|
159
163
|
require_paths:
|
160
164
|
- lib
|
161
165
|
required_ruby_version: !ruby/object:Gem::Requirement
|
162
166
|
requirements:
|
163
|
-
- - "
|
167
|
+
- - ">"
|
164
168
|
- !ruby/object:Gem::Version
|
165
|
-
version: '
|
169
|
+
version: '2.5'
|
166
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
171
|
requirements:
|
168
172
|
- - ">="
|
@@ -170,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
174
|
version: '0'
|
171
175
|
requirements: []
|
172
176
|
rubygems_version: 3.1.2
|
173
|
-
signing_key:
|
177
|
+
signing_key:
|
174
178
|
specification_version: 4
|
175
179
|
summary: Ruby Scheduler
|
176
180
|
test_files: []
|
data/Rakefile
DELETED