jobly 0.5.10 → 0.5.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/jobly +5 -5
- data/lib/jobly/api.rb +9 -10
- data/lib/jobly/cli.rb +4 -5
- data/lib/jobly/commands/base.rb +1 -1
- data/lib/jobly/commands/config.rb +7 -7
- data/lib/jobly/commands/info.rb +13 -12
- data/lib/jobly/commands/init.rb +7 -7
- data/lib/jobly/commands/run.rb +10 -11
- data/lib/jobly/commands/send.rb +7 -8
- data/lib/jobly/commands/server.rb +5 -5
- data/lib/jobly/commands/worker.rb +13 -11
- data/lib/jobly/exceptions.rb +1 -1
- data/lib/jobly/extensions/integer.rb +5 -5
- data/lib/jobly/helpers/logging.rb +1 -1
- data/lib/jobly/helpers/settings.rb +1 -1
- data/lib/jobly/helpers/shell.rb +2 -2
- data/lib/jobly/helpers/slack.rb +4 -4
- data/lib/jobly/job.rb +2 -5
- data/lib/jobly/job_extensions/actions.rb +0 -1
- data/lib/jobly/job_extensions/isolation.rb +2 -2
- data/lib/jobly/job_extensions/option_accessors.rb +1 -3
- data/lib/jobly/job_extensions/solo.rb +1 -2
- data/lib/jobly/jobs.rb +0 -1
- data/lib/jobly/log.rb +19 -20
- data/lib/jobly/module_functions.rb +23 -28
- data/lib/jobly/refinements/argument_converters.rb +2 -2
- data/lib/jobly/refinements/convert_to_typed.rb +4 -3
- data/lib/jobly/refinements/keyword_args.rb +3 -3
- data/lib/jobly/refinements/to_slug.rb +1 -1
- data/lib/jobly/server.rb +4 -8
- data/lib/jobly/sidekiq.rb +2 -2
- data/lib/jobly/templates/full/Gemfile +3 -3
- data/lib/jobly/templates/full/app/job.rb +1 -1
- data/lib/jobly/templates/full/app/other_class.rb +1 -1
- data/lib/jobly/templates/full/config/jobly.rb +1 -1
- data/lib/jobly/templates/full/jobs/hello.rb +4 -4
- data/lib/jobly/templates/minimal/Gemfile +2 -2
- data/lib/jobly/version.rb +2 -2
- data/lib/jobly.rb +0 -1
- metadata +39 -45
- data/lib/jobly/polyfills/hash.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62fba0cb854e3268a518c5779f247f465af83e85caaacb9a4442e907685e336a
|
4
|
+
data.tar.gz: d671bae5e151d244c1a901eb3a353be41810bfb9d0e328e471b444ca2f7d9495
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6918115853f589511eb2e3152ecbc45eb62576e76bd82c280a93ff121522d23ec99528a029200cef5d516f7ab3d26bba5c12b80f5976d148c7ec826711cec05e
|
7
|
+
data.tar.gz: 592f0f2142e689fcf33b435c39649a170d92cb1c5aec69a4b8b26cbd2ac15028ff261c73c8360f451f220ea222bac4386bc3d574a8fcfc654aaeba668bcd851a
|
data/bin/jobly
CHANGED
@@ -4,11 +4,11 @@ require 'jobly'
|
|
4
4
|
require 'jobly/boot'
|
5
5
|
|
6
6
|
PrettyTrace.filter [
|
7
|
-
|
8
|
-
%r
|
9
|
-
%r
|
10
|
-
%r
|
11
|
-
%r
|
7
|
+
/mister_bin/,
|
8
|
+
%r{bin/jobly},
|
9
|
+
%r{bin/ruby},
|
10
|
+
%r{lib/ruby},
|
11
|
+
%r{lib/jobly},
|
12
12
|
]
|
13
13
|
|
14
14
|
router = Jobly::CLI.router
|
data/lib/jobly/api.rb
CHANGED
@@ -6,7 +6,6 @@ require 'sinatra/reloader'
|
|
6
6
|
require 'sinatra/custom_logger'
|
7
7
|
|
8
8
|
module Jobly
|
9
|
-
|
10
9
|
class API < Sinatra::Application
|
11
10
|
helpers Sinatra::CustomLogger
|
12
11
|
using ConvertToTyped
|
@@ -27,7 +26,7 @@ module Jobly
|
|
27
26
|
get '/' do
|
28
27
|
{
|
29
28
|
version: Jobly::VERSION,
|
30
|
-
message: %
|
29
|
+
message: %["I'm gonna live till I die" - Frank Sinatra],
|
31
30
|
}.to_json + "\n"
|
32
31
|
end
|
33
32
|
|
@@ -45,15 +44,15 @@ module Jobly
|
|
45
44
|
|
46
45
|
private
|
47
46
|
|
48
|
-
def add_job(job, args={})
|
47
|
+
def add_job(job, args = {})
|
49
48
|
job_class = Jobs.get_class job
|
50
49
|
|
51
|
-
|
50
|
+
unless job_class
|
52
51
|
response = {
|
53
|
-
status:
|
52
|
+
status: 'error',
|
54
53
|
message: 'No such job',
|
55
|
-
job:
|
56
|
-
params:
|
54
|
+
job: job,
|
55
|
+
params: args,
|
57
56
|
}
|
58
57
|
|
59
58
|
status 404
|
@@ -67,15 +66,15 @@ module Jobly
|
|
67
66
|
else
|
68
67
|
job_class.run_later args
|
69
68
|
end
|
70
|
-
|
69
|
+
|
71
70
|
response = {
|
72
71
|
status: 'received',
|
73
|
-
job:
|
72
|
+
job: job,
|
74
73
|
params: args,
|
75
74
|
}
|
76
75
|
|
77
76
|
logger.debug "[jobly server] Job received (#{job})"
|
78
|
-
response.to_json
|
77
|
+
"#{response.to_json}\n"
|
79
78
|
end
|
80
79
|
end
|
81
80
|
end
|
data/lib/jobly/cli.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'mister_bin'
|
2
2
|
require 'jobly/version'
|
3
|
-
requires 'commands/base'
|
3
|
+
requires 'commands/base'
|
4
|
+
requires 'commands'
|
4
5
|
|
5
6
|
module Jobly
|
6
|
-
|
7
7
|
# Command line interface router. This is called by bin/jobly.
|
8
8
|
class CLI
|
9
9
|
def self.router
|
10
10
|
router = MisterBin::Runner.new version: Jobly::VERSION,
|
11
|
-
header:
|
12
|
-
footer:
|
11
|
+
header: 'Jobly',
|
12
|
+
footer: 'Run !txtpur!jobly COMMAND --help!txtrst! for more information'
|
13
13
|
|
14
14
|
router.route 'init', to: Commands::InitCmd
|
15
15
|
router.route 'server', to: Commands::ServerCmd
|
@@ -22,5 +22,4 @@ module Jobly
|
|
22
22
|
router
|
23
23
|
end
|
24
24
|
end
|
25
|
-
|
26
25
|
end
|
data/lib/jobly/commands/base.rb
CHANGED
@@ -3,16 +3,17 @@ require 'pathname'
|
|
3
3
|
module Jobly
|
4
4
|
module Commands
|
5
5
|
class ConfigCmd < Base
|
6
|
-
summary
|
7
|
-
usage
|
8
|
-
usage
|
6
|
+
summary 'Show configuration options'
|
7
|
+
usage 'jobly config'
|
8
|
+
usage 'jobly config (-h|--help)'
|
9
9
|
|
10
10
|
def run
|
11
|
-
line
|
11
|
+
line 'custom config file', short_config_path, attention: !Jobly.custom_config?
|
12
12
|
Jobly.options.each do |key, value|
|
13
13
|
next unless value
|
14
|
+
|
14
15
|
if key.to_s.end_with? '_path'
|
15
|
-
line key, value, !Dir.exist?(value)
|
16
|
+
line key, value, attention: !Dir.exist?(value)
|
16
17
|
else
|
17
18
|
line key, value
|
18
19
|
end
|
@@ -25,11 +26,10 @@ module Jobly
|
|
25
26
|
Jobly.config_file.sub "#{Dir.pwd}/", ''
|
26
27
|
end
|
27
28
|
|
28
|
-
def line(key, value, attention
|
29
|
+
def line(key, value, attention: false)
|
29
30
|
color = attention ? '!txtred!' : '!txtgrn!'
|
30
31
|
say "#{key.to_s.rjust 20} #{color}#{value.to_s.strip}"
|
31
32
|
end
|
32
|
-
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
data/lib/jobly/commands/info.rb
CHANGED
@@ -3,25 +3,27 @@ require 'tty-markdown'
|
|
3
3
|
module Jobly
|
4
4
|
module Commands
|
5
5
|
class InfoCmd < Base
|
6
|
-
summary
|
7
|
-
usage
|
8
|
-
usage
|
6
|
+
summary 'Show workspace info'
|
7
|
+
usage 'jobly info'
|
8
|
+
usage 'jobly info (-h|--help)'
|
9
9
|
|
10
10
|
def run
|
11
11
|
raise InfoFileNotFound, info_file unless File.exist? info_file
|
12
|
+
|
12
13
|
puts TTY::Markdown.parse(info, theme: {
|
13
|
-
header: [
|
14
|
-
em:
|
15
|
-
hr:
|
16
|
-
link:
|
17
|
-
list:
|
18
|
-
strong: [
|
19
|
-
table:
|
20
|
-
quote:
|
14
|
+
header: %i[green bold],
|
15
|
+
em: %i[magenta bold],
|
16
|
+
hr: :yellow,
|
17
|
+
link: %i[blue underline],
|
18
|
+
list: :cyan,
|
19
|
+
strong: %i[cyan bold],
|
20
|
+
table: :yellow,
|
21
|
+
quote: :magenta,
|
21
22
|
})
|
22
23
|
end
|
23
24
|
|
24
25
|
private
|
26
|
+
|
25
27
|
def info
|
26
28
|
@info ||= File.read info_file
|
27
29
|
end
|
@@ -29,7 +31,6 @@ module Jobly
|
|
29
31
|
def info_file
|
30
32
|
@info_file ||= File.expand_path 'info.md', Jobly.config_path
|
31
33
|
end
|
32
|
-
|
33
34
|
end
|
34
35
|
end
|
35
36
|
end
|
data/lib/jobly/commands/init.rb
CHANGED
@@ -3,13 +3,13 @@ require 'fileutils'
|
|
3
3
|
module Jobly
|
4
4
|
module Commands
|
5
5
|
class InitCmd < Base
|
6
|
-
summary
|
7
|
-
usage
|
8
|
-
usage
|
9
|
-
param
|
10
|
-
option
|
11
|
-
example
|
12
|
-
example
|
6
|
+
summary 'Create an initial jobs workspace'
|
7
|
+
usage 'jobly init NAME [--minimal]'
|
8
|
+
usage 'jobly init (-h|--help)'
|
9
|
+
param 'NAME', 'The name of the folder to create'
|
10
|
+
option '-m --minimal', 'Create a minimal workspace'
|
11
|
+
example 'jobly init test'
|
12
|
+
example 'jobly init myjobs --minimal'
|
13
13
|
|
14
14
|
def run
|
15
15
|
raise ArgumentError, "#{target_dir} already exists" if File.exist? target_dir
|
data/lib/jobly/commands/run.rb
CHANGED
@@ -4,15 +4,15 @@ module Jobly
|
|
4
4
|
using ArgumentConverters
|
5
5
|
using ConvertToTyped
|
6
6
|
|
7
|
-
summary
|
8
|
-
usage
|
9
|
-
usage
|
10
|
-
option
|
11
|
-
param
|
12
|
-
param
|
13
|
-
example
|
14
|
-
example
|
15
|
-
example
|
7
|
+
summary 'Run a job locally'
|
8
|
+
usage 'jobly run [--later] JOB [PARAMS...]'
|
9
|
+
usage 'jobly run (-h|--help)'
|
10
|
+
option '-l --later', 'Schedule the job to be executed later by a worker instead of running it immediately'
|
11
|
+
param 'JOB', 'Job name'
|
12
|
+
param 'PARAMS', 'Parameters to pass to the job as key:value'
|
13
|
+
example 'jobly run Greet name:Bob'
|
14
|
+
example 'jobly run --later Greet name:Bob'
|
15
|
+
example 'jobly run Deploy env:stage branch:master'
|
16
16
|
|
17
17
|
def run
|
18
18
|
job = args['JOB']
|
@@ -26,13 +26,12 @@ module Jobly
|
|
26
26
|
else
|
27
27
|
job_class.run_later params
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
else
|
31
31
|
say "Running !txtgrn!#{job_class}"
|
32
32
|
job_class.run params
|
33
33
|
end
|
34
34
|
end
|
35
|
-
|
36
35
|
end
|
37
36
|
end
|
38
37
|
end
|
data/lib/jobly/commands/send.rb
CHANGED
@@ -5,13 +5,13 @@ module Jobly
|
|
5
5
|
class SendCmd < Base
|
6
6
|
using ArgumentConverters
|
7
7
|
|
8
|
-
summary
|
9
|
-
usage
|
10
|
-
usage
|
11
|
-
param
|
12
|
-
param
|
13
|
-
example
|
14
|
-
example
|
8
|
+
summary 'Send a job to the API'
|
9
|
+
usage 'jobly send JOB [PARAMS...]'
|
10
|
+
usage 'jobly send (-h|--help)'
|
11
|
+
param 'JOB', 'Job name'
|
12
|
+
param 'PARAMS', 'Parameters to pass to the job as key:value'
|
13
|
+
example 'jobly send Greet name:Bob'
|
14
|
+
example 'jobly send Deploy env:stage branch:master'
|
15
15
|
|
16
16
|
def run
|
17
17
|
job = args['JOB']
|
@@ -43,7 +43,6 @@ module Jobly
|
|
43
43
|
HTTP
|
44
44
|
end
|
45
45
|
end
|
46
|
-
|
47
46
|
end
|
48
47
|
end
|
49
48
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module Jobly
|
2
2
|
module Commands
|
3
3
|
class ServerCmd < Base
|
4
|
-
summary
|
5
|
-
usage
|
6
|
-
usage
|
7
|
-
option
|
4
|
+
summary 'Start the server'
|
5
|
+
usage 'jobly server [--port NUMBER]'
|
6
|
+
usage 'jobly server (-h|--help)'
|
7
|
+
option '-p --port NUMBER', 'Set the port number [default: 3000]'
|
8
8
|
|
9
9
|
def run
|
10
10
|
port = args['--port']
|
11
|
-
say
|
11
|
+
say 'Starting server'
|
12
12
|
exec "rackup --env #{Jobly.environment} --port #{port} --host 0.0.0.0 #{rackup_file}"
|
13
13
|
end
|
14
14
|
|
@@ -1,19 +1,20 @@
|
|
1
1
|
module Jobly
|
2
2
|
module Commands
|
3
3
|
class WorkerCmd < Base
|
4
|
-
summary
|
5
|
-
usage
|
6
|
-
usage
|
7
|
-
option
|
8
|
-
option
|
9
|
-
|
4
|
+
summary 'Start a job worker'
|
5
|
+
usage 'jobly worker [-c COUNT -C PATH (-q NAME)...]'
|
6
|
+
usage 'jobly worker (-h|--help)'
|
7
|
+
option '-c --concurrency COUNT', 'Number of parallel jobs [default: 4]'
|
8
|
+
option '-C --config PATH',
|
9
|
+
'Specify a path to a YAML config file. The provided path should be relative to the global config_path directory and without the yml extension'
|
10
|
+
option '-q --queue NAME[,WEIGHT]', 'Specify one or more queues that this worker should handle'
|
10
11
|
|
11
|
-
example
|
12
|
-
example
|
13
|
-
example
|
12
|
+
example 'jobly worker --concurrency 10'
|
13
|
+
example 'jobly worker -q critical -q default -q low'
|
14
|
+
example 'jobly worker --config primary'
|
14
15
|
|
15
16
|
def run
|
16
|
-
say
|
17
|
+
say 'Starting sidekiq'
|
17
18
|
exec "sidekiq #{options_from_args}"
|
18
19
|
end
|
19
20
|
|
@@ -28,9 +29,10 @@ module Jobly
|
|
28
29
|
if args['--config']
|
29
30
|
config_file = "#{Jobly.config_path}/#{args['--config']}.yml"
|
30
31
|
raise ArgumentError, "Config not found: #{config_file}" unless File.exist? config_file
|
32
|
+
|
31
33
|
result << "--config \"#{config_file}\""
|
32
34
|
end
|
33
|
-
|
35
|
+
|
34
36
|
args['--queue'].each { |q| result << "--queue #{q}" }
|
35
37
|
|
36
38
|
result.join ' '
|
data/lib/jobly/exceptions.rb
CHANGED
@@ -2,20 +2,20 @@ class Integer
|
|
2
2
|
def seconds
|
3
3
|
self
|
4
4
|
end
|
5
|
-
|
5
|
+
alias second seconds
|
6
6
|
|
7
7
|
def minutes
|
8
8
|
60 * seconds
|
9
9
|
end
|
10
|
-
|
10
|
+
alias minute minutes
|
11
11
|
|
12
12
|
def hours
|
13
13
|
60 * minutes
|
14
14
|
end
|
15
|
-
|
15
|
+
alias hour hours
|
16
16
|
|
17
17
|
def days
|
18
18
|
24 * hours
|
19
19
|
end
|
20
|
-
|
21
|
-
end
|
20
|
+
alias day days
|
21
|
+
end
|
data/lib/jobly/helpers/shell.rb
CHANGED
data/lib/jobly/helpers/slack.rb
CHANGED
@@ -29,13 +29,13 @@ module Jobly
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def slack!
|
32
|
-
raise ArgumentError,
|
32
|
+
raise ArgumentError, 'Slack webhook is not set' unless Jobly.slack_webhook
|
33
|
+
|
33
34
|
opts = {
|
34
|
-
channel:
|
35
|
-
username: self.class.slack_user
|
35
|
+
channel: self.class.slack_channel,
|
36
|
+
username: self.class.slack_user,
|
36
37
|
}
|
37
38
|
::Slack::Notifier.new Jobly.slack_webhook, opts
|
38
39
|
end
|
39
|
-
|
40
40
|
end
|
41
41
|
end
|
data/lib/jobly/job.rb
CHANGED
@@ -31,7 +31,7 @@ module Jobly
|
|
31
31
|
|
32
32
|
# This is the method sidekiq will call. We capture this call and convert
|
33
33
|
# the hash argument which was converted to array on sidekiq's side, back
|
34
|
-
# to a hash so we can forward to the job's `execute` method, which may
|
34
|
+
# to a hash so we can forward to the job's `execute` method, which may
|
35
35
|
# implement keyword args.
|
36
36
|
# If the job was marked as isolated, we will run it in its own temporary
|
37
37
|
# directory.
|
@@ -63,20 +63,17 @@ module Jobly
|
|
63
63
|
run_actions :after
|
64
64
|
return false
|
65
65
|
end
|
66
|
-
|
66
|
+
true
|
67
67
|
end
|
68
68
|
|
69
69
|
def run_to_completion
|
70
70
|
params.empty? ? execute : execute(**params.to_kwargs)
|
71
71
|
run_actions :success
|
72
|
-
|
73
72
|
rescue
|
74
73
|
run_actions :failure
|
75
74
|
raise
|
76
|
-
|
77
75
|
ensure
|
78
76
|
run_actions :after
|
79
|
-
|
80
77
|
end
|
81
78
|
end
|
82
79
|
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
module Jobly
|
2
2
|
module JobExtensions
|
3
3
|
module OptionAccessors
|
4
|
-
|
5
4
|
def self.included(base)
|
6
5
|
base.extend ClassMethods
|
7
6
|
end
|
8
|
-
|
7
|
+
|
9
8
|
module ClassMethods
|
10
9
|
def options
|
11
10
|
sidekiq_options
|
@@ -28,7 +27,6 @@ module Jobly
|
|
28
27
|
# sidekiq_options_hash # is this better?
|
29
28
|
self.class.options
|
30
29
|
end
|
31
|
-
|
32
30
|
end
|
33
31
|
end
|
34
32
|
end
|
@@ -48,7 +48,7 @@ module Jobly
|
|
48
48
|
|
49
49
|
def solo_lock(expire = 1.hour)
|
50
50
|
Sidekiq.redis do |redis|
|
51
|
-
redis.setex(solo_full_key, expire,
|
51
|
+
redis.setex(solo_full_key, expire, '1')
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -57,7 +57,6 @@ module Jobly
|
|
57
57
|
redis.del solo_full_key
|
58
58
|
end
|
59
59
|
end
|
60
|
-
|
61
60
|
end
|
62
61
|
end
|
63
62
|
end
|
data/lib/jobly/jobs.rb
CHANGED
data/lib/jobly/log.rb
CHANGED
@@ -3,30 +3,29 @@ require 'uri'
|
|
3
3
|
|
4
4
|
module Jobly
|
5
5
|
module Log
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
class << self
|
7
|
+
def new(target = nil, tag = nil)
|
8
|
+
if !target || (target.to_sym == :stdout) || (target == $stdout)
|
9
|
+
return Logger.new $stdout
|
10
|
+
end
|
11
|
+
|
12
|
+
target = target.to_s
|
13
|
+
target %= tag if tag && target.include?('%s')
|
14
|
+
|
15
|
+
if target.start_with? 'syslog://'
|
16
|
+
remote_syslog_logger target
|
17
|
+
else
|
18
|
+
Logger.new File.expand_path(target, Jobly.root)
|
19
|
+
end
|
9
20
|
end
|
10
21
|
|
11
|
-
|
12
|
-
target %= tag if tag and target.include? "%s"
|
22
|
+
private
|
13
23
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
24
|
+
def remote_syslog_logger(target)
|
25
|
+
uri = URI target
|
26
|
+
RemoteSyslogLogger.new (uri.host || 'localhost'), (uri.port || 514),
|
27
|
+
local_hostname: uri.user, program: uri.password
|
18
28
|
end
|
19
29
|
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def self.remote_syslog_logger(target)
|
24
|
-
uri = URI target
|
25
|
-
RemoteSyslogLogger.new (uri.host || 'localhost'), (uri.port || 514),
|
26
|
-
local_hostname: uri.user, program: uri.password
|
27
|
-
end
|
28
30
|
end
|
29
31
|
end
|
30
|
-
|
31
|
-
|
32
|
-
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Jobly
|
2
2
|
class << self
|
3
|
+
attr_reader :logger
|
4
|
+
|
3
5
|
def configure
|
4
6
|
yield self
|
5
7
|
end
|
@@ -10,30 +12,30 @@ module Jobly
|
|
10
12
|
|
11
13
|
def default_options
|
12
14
|
{
|
13
|
-
root:
|
14
|
-
environment:
|
15
|
-
api_url:
|
16
|
-
app_path:
|
17
|
-
jobs_path:
|
18
|
-
config_path:
|
19
|
-
redis_url:
|
15
|
+
root: Dir.pwd,
|
16
|
+
environment: ENV['JOBLY_ENVIRONMENT'] || 'development',
|
17
|
+
api_url: ENV['JOBLY_API_URL'] || 'http://localhost:3000/do',
|
18
|
+
app_path: ENV['JOBLY_APP_PATH'] || 'app',
|
19
|
+
jobs_path: ENV['JOBLY_JOBS_PATH'] || 'jobs',
|
20
|
+
config_path: ENV['JOBLY_CONFIG_PATH'] || 'config',
|
21
|
+
redis_url: ENV['JOBLY_REDIS_URL'] || 'redis://localhost:6379/0',
|
20
22
|
status_expiration: ENV['JOBLY_STATUS_EXPIRATION']&.to_i || 30,
|
21
|
-
jobs_namespace:
|
22
|
-
slack_webhook:
|
23
|
-
slack_channel:
|
24
|
-
slack_user:
|
25
|
-
log:
|
26
|
-
log_level:
|
27
|
-
auth:
|
28
|
-
secret:
|
29
|
-
shell_dry_run:
|
30
|
-
mounts:
|
23
|
+
jobs_namespace: ENV['JOBLY_JOBS_NAMESPACE'],
|
24
|
+
slack_webhook: ENV['JOBLY_SLACK_WEBHOOK'],
|
25
|
+
slack_channel: ENV['JOBLY_SLACK_CHANNEL'] || '#general',
|
26
|
+
slack_user: ENV['JOBLY_SLACK_USER'] || 'Jobly',
|
27
|
+
log: ENV['JOBLY_LOG'],
|
28
|
+
log_level: ENV['JOBLY_LOG_LEVEL'] || 'info',
|
29
|
+
auth: ENV['JOBLY_AUTH'],
|
30
|
+
secret: ENV['JOBLY_SECRET'] || 'change-this-cookie-secret',
|
31
|
+
shell_dry_run: ENV['JOBLY_SHELL_DRY_RUN'],
|
32
|
+
mounts: nil,
|
31
33
|
}
|
32
34
|
end
|
33
35
|
|
34
|
-
def method_missing(method, args=nil, &_block)
|
36
|
+
def method_missing(method, args = nil, &_block)
|
35
37
|
key = method.to_s
|
36
|
-
assign = key[-1] ==
|
38
|
+
assign = key[-1] == '='
|
37
39
|
key = key.chomp('=') if assign
|
38
40
|
key = key.to_sym
|
39
41
|
|
@@ -44,7 +46,7 @@ module Jobly
|
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
47
|
-
def respond_to_missing?(method, include_private=false)
|
49
|
+
def respond_to_missing?(method, include_private = false)
|
48
50
|
key = method.to_s.chomp('=').to_sym
|
49
51
|
options.has_key?(key) ? true : super
|
50
52
|
end
|
@@ -53,22 +55,15 @@ module Jobly
|
|
53
55
|
@options ||= default_options.dup
|
54
56
|
end
|
55
57
|
|
56
|
-
def logger
|
57
|
-
@logger
|
58
|
-
end
|
59
|
-
|
60
58
|
def log=(target)
|
61
59
|
options[:log] = target
|
62
60
|
@logger = if target.is_a? Logger
|
63
61
|
target
|
64
62
|
elsif target
|
65
63
|
Log.new target, :jobly
|
66
|
-
else
|
67
|
-
nil
|
68
64
|
end
|
69
65
|
|
70
|
-
@logger.level = log_level if @logger
|
71
|
-
@logger
|
66
|
+
@logger.level = log_level if @logger && @logger.respond_to?(:level)
|
72
67
|
end
|
73
68
|
|
74
69
|
def full_app_path
|
@@ -18,10 +18,11 @@ module Jobly
|
|
18
18
|
|
19
19
|
refine String do
|
20
20
|
def convert_to_typed
|
21
|
-
return true if [
|
22
|
-
return false if [
|
21
|
+
return true if %w[true yes].include? self
|
22
|
+
return false if %w[false no].include? self
|
23
|
+
|
23
24
|
Integer self rescue self
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
27
|
-
end
|
28
|
+
end
|
@@ -2,14 +2,14 @@ module Jobly
|
|
2
2
|
module KeywordArgs
|
3
3
|
refine Hash do
|
4
4
|
def to_kwargs
|
5
|
-
to_h.transform_keys
|
5
|
+
to_h.transform_keys(&:to_sym)
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
9
|
refine Array do
|
10
10
|
def to_kwargs
|
11
|
-
to_h.transform_keys
|
11
|
+
to_h.transform_keys(&:to_sym)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
15
|
-
end
|
15
|
+
end
|
data/lib/jobly/server.rb
CHANGED
@@ -10,8 +10,8 @@ module Jobly
|
|
10
10
|
|
11
11
|
def self.app
|
12
12
|
mounts = {
|
13
|
-
'/' => Sidekiq::Web,
|
14
|
-
'/do' => Jobly::API
|
13
|
+
'/' => Sidekiq::Web,
|
14
|
+
'/do' => Jobly::API,
|
15
15
|
}
|
16
16
|
mounts.merge! Jobly.mounts if Jobly.mounts
|
17
17
|
|
@@ -21,7 +21,7 @@ module Jobly
|
|
21
21
|
|
22
22
|
if Jobly.auth
|
23
23
|
user, pass = Jobly.auth.split ':'
|
24
|
-
use Rack::Auth::Basic,
|
24
|
+
use Rack::Auth::Basic, 'Jobly' do |username, password|
|
25
25
|
username == user && password == pass
|
26
26
|
end
|
27
27
|
end
|
@@ -29,9 +29,5 @@ module Jobly
|
|
29
29
|
run Rack::URLMap.new mounts
|
30
30
|
end
|
31
31
|
end
|
32
|
-
end
|
32
|
+
end
|
33
33
|
end
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
data/lib/jobly/sidekiq.rb
CHANGED
@@ -8,19 +8,19 @@ module Jobly
|
|
8
8
|
def self.configure
|
9
9
|
Sidekiq.configure_client do |config|
|
10
10
|
config.redis = { url: Jobly.redis_url }
|
11
|
+
config.logger = Jobly.logger if Jobly.log
|
11
12
|
Sidekiq::Status.configure_client_middleware config, expiration: 60 * 60
|
12
13
|
end
|
13
14
|
|
14
15
|
Sidekiq.configure_server do |config|
|
15
16
|
# :nocov:
|
16
17
|
config.redis = { url: Jobly.redis_url }
|
18
|
+
config.logger = Jobly.logger if Jobly.log
|
17
19
|
|
18
20
|
Sidekiq::Status.configure_server_middleware config, expiration: Jobly.status_expiration * 60
|
19
21
|
Sidekiq::Status.configure_client_middleware config, expiration: Jobly.status_expiration * 60
|
20
22
|
# :nocov:
|
21
23
|
end
|
22
|
-
|
23
|
-
Sidekiq.logger = Jobly.logger if Jobly.log
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem
|
4
|
-
gem
|
3
|
+
gem 'foreman'
|
4
|
+
gem 'jobly'
|
@@ -2,15 +2,15 @@
|
|
2
2
|
class Hello < Job
|
3
3
|
def execute(name: 'Bob')
|
4
4
|
total 2
|
5
|
-
|
6
|
-
at 0,
|
5
|
+
|
6
|
+
at 0, 'Initializing'
|
7
7
|
sleep rand 3.0..8.0
|
8
8
|
|
9
|
-
at 1,
|
9
|
+
at 1, 'Preparing to say Hi'
|
10
10
|
sleep rand 3.0..8.0
|
11
11
|
|
12
12
|
logger.info "Hi #{name}!"
|
13
13
|
|
14
|
-
at 2,
|
14
|
+
at 2, 'Done'
|
15
15
|
end
|
16
16
|
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem
|
3
|
+
gem 'jobly'
|
data/lib/jobly/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Jobly
|
2
|
-
VERSION =
|
3
|
-
end
|
2
|
+
VERSION = '0.5.11'
|
3
|
+
end
|
data/lib/jobly.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jobly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colsole
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.7.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.7.0
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: http
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -25,13 +39,24 @@ dependencies:
|
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: '5.0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
42
|
+
name: mister_bin
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
-
|
47
|
+
version: 0.7.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.7.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pretty_trace
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
35
60
|
- !ruby/object:Gem::Version
|
36
61
|
version: 0.2.4
|
37
62
|
type: :runtime
|
@@ -39,9 +64,6 @@ dependencies:
|
|
39
64
|
version_requirements: !ruby/object:Gem::Requirement
|
40
65
|
requirements:
|
41
66
|
- - "~>"
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '0.2'
|
44
|
-
- - ">="
|
45
67
|
- !ruby/object:Gem::Version
|
46
68
|
version: 0.2.4
|
47
69
|
- !ruby/object:Gem::Dependency
|
@@ -84,28 +106,28 @@ dependencies:
|
|
84
106
|
requirements:
|
85
107
|
- - "~>"
|
86
108
|
- !ruby/object:Gem::Version
|
87
|
-
version: '0
|
109
|
+
version: '1.0'
|
88
110
|
type: :runtime
|
89
111
|
prerelease: false
|
90
112
|
version_requirements: !ruby/object:Gem::Requirement
|
91
113
|
requirements:
|
92
114
|
- - "~>"
|
93
115
|
- !ruby/object:Gem::Version
|
94
|
-
version: '0
|
116
|
+
version: '1.0'
|
95
117
|
- !ruby/object:Gem::Dependency
|
96
118
|
name: sidekiq
|
97
119
|
requirement: !ruby/object:Gem::Requirement
|
98
120
|
requirements:
|
99
121
|
- - "~>"
|
100
122
|
- !ruby/object:Gem::Version
|
101
|
-
version: '6.
|
123
|
+
version: '6.5'
|
102
124
|
type: :runtime
|
103
125
|
prerelease: false
|
104
126
|
version_requirements: !ruby/object:Gem::Requirement
|
105
127
|
requirements:
|
106
128
|
- - "~>"
|
107
129
|
- !ruby/object:Gem::Version
|
108
|
-
version: '6.
|
130
|
+
version: '6.5'
|
109
131
|
- !ruby/object:Gem::Dependency
|
110
132
|
name: sidekiq-status
|
111
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -168,14 +190,14 @@ dependencies:
|
|
168
190
|
requirements:
|
169
191
|
- - "~>"
|
170
192
|
- !ruby/object:Gem::Version
|
171
|
-
version:
|
193
|
+
version: 0.5.0
|
172
194
|
type: :runtime
|
173
195
|
prerelease: false
|
174
196
|
version_requirements: !ruby/object:Gem::Requirement
|
175
197
|
requirements:
|
176
198
|
- - "~>"
|
177
199
|
- !ruby/object:Gem::Version
|
178
|
-
version:
|
200
|
+
version: 0.5.0
|
179
201
|
- !ruby/object:Gem::Dependency
|
180
202
|
name: tty-command
|
181
203
|
requirement: !ruby/object:Gem::Requirement
|
@@ -204,34 +226,6 @@ dependencies:
|
|
204
226
|
- - "~>"
|
205
227
|
- !ruby/object:Gem::Version
|
206
228
|
version: '0.6'
|
207
|
-
- !ruby/object:Gem::Dependency
|
208
|
-
name: colsole
|
209
|
-
requirement: !ruby/object:Gem::Requirement
|
210
|
-
requirements:
|
211
|
-
- - "~>"
|
212
|
-
- !ruby/object:Gem::Version
|
213
|
-
version: '0.6'
|
214
|
-
type: :runtime
|
215
|
-
prerelease: false
|
216
|
-
version_requirements: !ruby/object:Gem::Requirement
|
217
|
-
requirements:
|
218
|
-
- - "~>"
|
219
|
-
- !ruby/object:Gem::Version
|
220
|
-
version: '0.6'
|
221
|
-
- !ruby/object:Gem::Dependency
|
222
|
-
name: mister_bin
|
223
|
-
requirement: !ruby/object:Gem::Requirement
|
224
|
-
requirements:
|
225
|
-
- - "~>"
|
226
|
-
- !ruby/object:Gem::Version
|
227
|
-
version: '0.7'
|
228
|
-
type: :runtime
|
229
|
-
prerelease: false
|
230
|
-
version_requirements: !ruby/object:Gem::Requirement
|
231
|
-
requirements:
|
232
|
-
- - "~>"
|
233
|
-
- !ruby/object:Gem::Version
|
234
|
-
version: '0.7'
|
235
229
|
description: Execute background jobs and build tasks on this sidekiq-based job server
|
236
230
|
email: db@dannyben.com
|
237
231
|
executables:
|
@@ -270,7 +264,6 @@ files:
|
|
270
264
|
- lib/jobly/jobs.rb
|
271
265
|
- lib/jobly/log.rb
|
272
266
|
- lib/jobly/module_functions.rb
|
273
|
-
- lib/jobly/polyfills/hash.rb
|
274
267
|
- lib/jobly/refinements/argument_converters.rb
|
275
268
|
- lib/jobly/refinements/convert_to_typed.rb
|
276
269
|
- lib/jobly/refinements/keyword_args.rb
|
@@ -298,6 +291,7 @@ metadata:
|
|
298
291
|
changelog_uri: https://github.com/DannyBen/jobly/blob/master/CHANGELOG.md
|
299
292
|
documentation_uri: https://jobly.dannyb.co/
|
300
293
|
source_code_uri: https://github.com/dannyben/jobly
|
294
|
+
rubygems_mfa_required: 'true'
|
301
295
|
post_install_message:
|
302
296
|
rdoc_options: []
|
303
297
|
require_paths:
|
@@ -306,14 +300,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
306
300
|
requirements:
|
307
301
|
- - ">="
|
308
302
|
- !ruby/object:Gem::Version
|
309
|
-
version: 2.
|
303
|
+
version: '2.7'
|
310
304
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
311
305
|
requirements:
|
312
306
|
- - ">="
|
313
307
|
- !ruby/object:Gem::Version
|
314
308
|
version: '0'
|
315
309
|
requirements: []
|
316
|
-
rubygems_version: 3.3
|
310
|
+
rubygems_version: 3.4.3
|
317
311
|
signing_key:
|
318
312
|
specification_version: 4
|
319
313
|
summary: Compact job server with API, CLI, Web UI and a Sidekiq heart
|
data/lib/jobly/polyfills/hash.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# :nocov:
|
2
|
-
|
3
|
-
# Required for Ruby < 2.4
|
4
|
-
if !{}.respond_to? :transform_values
|
5
|
-
class Hash
|
6
|
-
def transform_values
|
7
|
-
self.each { |k, v| self[k] = yield v }
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
# Required for Ruby < 2.5
|
13
|
-
if !{}.respond_to? :transform_keys
|
14
|
-
class Hash
|
15
|
-
def transform_keys
|
16
|
-
self.map { |k, v| [(yield k), v] }.to_h
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# :nocov:
|