jobly 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/bin/jobly +7 -5
- data/lib/jobly.rb +1 -0
- data/lib/jobly/api.rb +79 -0
- data/lib/jobly/commands/send.rb +21 -10
- data/lib/jobly/config.ru +1 -6
- data/lib/jobly/exceptions.rb +1 -0
- data/lib/jobly/module_functions.rb +2 -0
- data/lib/jobly/server.rb +21 -67
- data/lib/jobly/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbc38c3493fa50569ff1b574727a9d854d9c64694d8d7d1ece218ee0e78dd6c4
|
4
|
+
data.tar.gz: 518ad55187220df99d35d18b1a9cf9f7e22b0a7eb0455f36dc23c4202b9b7bfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2de8768494317847f01b52519bb2cfc374e30e885ba5a1ffa3cf801c5f966c63c2c1c1dbfe74f0a0e1f4614a14051ce86efbd8e8fead41bf44371a2f12b81bd
|
7
|
+
data.tar.gz: 9ae8b72be0ae7c4f79ed0616e990d9a58031c16bbe6d19db8236a7f600854fe6f605bcfdd46c1d292f753258c398e7f0bc3a608ea28ee9fe672d10b3dfe3a095
|
data/README.md
CHANGED
@@ -16,8 +16,8 @@ Compact job server with API, CLI, Web UI and a Sidekiq heart.
|
|
16
16
|
---
|
17
17
|
|
18
18
|
<table><tr>
|
19
|
-
<td width='50%'><a target='_screenshot' href='/
|
20
|
-
<td width='50%'><a target='_screenshot' href='/
|
19
|
+
<td width='50%'><a target='_screenshot' href='/assets/terminal.gif'><img src='/assets/terminal.gif'/></a></td>
|
20
|
+
<td width='50%'><a target='_screenshot' href='/assets/screen.gif'><img src='/assets/screen.gif'/></a></td>
|
21
21
|
</tr></table>
|
22
22
|
|
23
23
|
---
|
data/bin/jobly
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'colsole'
|
3
|
-
require 'jobly'
|
4
|
-
require 'jobly/boot'
|
5
|
-
|
6
3
|
include Colsole
|
7
4
|
|
8
|
-
router = Jobly::CLI.router
|
9
|
-
|
10
5
|
begin
|
6
|
+
require 'jobly'
|
7
|
+
require 'jobly/boot'
|
8
|
+
|
9
|
+
router = Jobly::CLI.router
|
10
|
+
|
11
11
|
exit router.run ARGV
|
12
|
+
|
12
13
|
rescue => e
|
13
14
|
puts e.backtrace.reverse if ENV['DEBUG']
|
14
15
|
say! "!txtred!#{e.class}: #{e.message}"
|
16
|
+
say! "Run with !txtpur!DEBUG=1!txtrst! for backtrace details" unless ENV['DEBUG']
|
15
17
|
exit 1
|
16
18
|
end
|
data/lib/jobly.rb
CHANGED
data/lib/jobly/api.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'jobly'
|
2
|
+
require 'sinatra/base'
|
3
|
+
require 'sinatra/reloader'
|
4
|
+
require 'sinatra/custom_logger'
|
5
|
+
|
6
|
+
module Jobly
|
7
|
+
|
8
|
+
class API < Sinatra::Application
|
9
|
+
helpers Sinatra::CustomLogger
|
10
|
+
using ConvertToTyped
|
11
|
+
|
12
|
+
configure :development, :production do
|
13
|
+
set :server, :puma
|
14
|
+
set :logger, Jobly.logger if Jobly.logger
|
15
|
+
end
|
16
|
+
|
17
|
+
configure :development do
|
18
|
+
register Sinatra::Reloader
|
19
|
+
end
|
20
|
+
|
21
|
+
before do
|
22
|
+
content_type 'application/json'
|
23
|
+
end
|
24
|
+
|
25
|
+
get '/' do
|
26
|
+
{
|
27
|
+
version: VERSION,
|
28
|
+
message: %Q["I'm gonna live till I die" - Frank Sinatra]
|
29
|
+
}.to_json
|
30
|
+
end
|
31
|
+
|
32
|
+
get '/*' do
|
33
|
+
job = params[:splat].first
|
34
|
+
params.delete :splat
|
35
|
+
add_job job, params
|
36
|
+
end
|
37
|
+
|
38
|
+
post '/*' do
|
39
|
+
job = params[:splat].first
|
40
|
+
params.delete :splat
|
41
|
+
add_job job, params
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def add_job(job, args={})
|
47
|
+
job_class = Jobs.get_class job
|
48
|
+
|
49
|
+
if !job_class
|
50
|
+
response = {
|
51
|
+
status: 'error',
|
52
|
+
message: 'No such job',
|
53
|
+
job: job,
|
54
|
+
params: args
|
55
|
+
}
|
56
|
+
|
57
|
+
status 404
|
58
|
+
logger.debug "[jobly server] No such job (#{job})"
|
59
|
+
return response.to_json
|
60
|
+
end
|
61
|
+
|
62
|
+
args = args.convert_to_typed
|
63
|
+
if args.empty?
|
64
|
+
job_class.perform_async
|
65
|
+
else
|
66
|
+
job_class.perform_async args
|
67
|
+
end
|
68
|
+
|
69
|
+
response = {
|
70
|
+
status: 'received',
|
71
|
+
job: job,
|
72
|
+
params: args,
|
73
|
+
}
|
74
|
+
|
75
|
+
logger.debug "[jobly server] Job received (#{job})"
|
76
|
+
response.to_json
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
data/lib/jobly/commands/send.rb
CHANGED
@@ -18,19 +18,30 @@ module Jobly
|
|
18
18
|
params = args['PARAMS'].to_params
|
19
19
|
url = "#{Jobly.api_url}/#{job}"
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
21
|
+
args = [url]
|
22
|
+
args << { params: params } unless params.empty?
|
23
|
+
|
24
|
+
response = client.get *args
|
26
25
|
|
27
|
-
|
28
|
-
|
26
|
+
raise HTTPError, "#{response.code} #{response.reason}" unless response.status.ok?
|
27
|
+
|
28
|
+
say "!txtgrn!#{response.code} #{response.reason}"
|
29
|
+
lp response.parse
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def client
|
35
|
+
@client ||= client!
|
36
|
+
end
|
37
|
+
|
38
|
+
def client!
|
39
|
+
if Jobly.auth
|
40
|
+
user, pass = Jobly.auth.split ':'
|
41
|
+
HTTP.basic_auth user: user, pass: pass
|
29
42
|
else
|
30
|
-
|
43
|
+
HTTP
|
31
44
|
end
|
32
|
-
|
33
|
-
lp response.parse
|
34
45
|
end
|
35
46
|
|
36
47
|
end
|
data/lib/jobly/config.ru
CHANGED
data/lib/jobly/exceptions.rb
CHANGED
data/lib/jobly/server.rb
CHANGED
@@ -1,79 +1,33 @@
|
|
1
1
|
require 'jobly'
|
2
|
-
require '
|
3
|
-
require 'sinatra/reloader'
|
4
|
-
require 'sinatra/custom_logger'
|
2
|
+
require 'rack'
|
5
3
|
|
6
4
|
module Jobly
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
using ConvertToTyped
|
11
|
-
|
12
|
-
configure :development, :production do
|
13
|
-
set :server, :puma
|
14
|
-
set :logger, Jobly.logger if Jobly.logger
|
5
|
+
class Server
|
6
|
+
def self.call(env)
|
7
|
+
app.call env
|
15
8
|
end
|
16
9
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
get '/' do
|
26
|
-
{
|
27
|
-
version: VERSION,
|
28
|
-
message: %Q["I'm gonna live till I die" - Frank Sinatra]
|
29
|
-
}.to_json
|
30
|
-
end
|
10
|
+
def self.app
|
11
|
+
mounts = {
|
12
|
+
'/' => Sidekiq::Web,
|
13
|
+
'/do' => Jobly::API
|
14
|
+
}
|
15
|
+
mounts.merge! Jobly.mounts if Jobly.mounts
|
31
16
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
17
|
+
Rack::Builder.new do
|
18
|
+
if Jobly.auth
|
19
|
+
user, pass = Jobly.auth.split ':'
|
20
|
+
use Rack::Auth::Basic, "Jobly" do |username, password|
|
21
|
+
username == user && password == pass
|
22
|
+
end
|
23
|
+
end
|
37
24
|
|
38
|
-
|
39
|
-
|
40
|
-
params.delete :splat
|
41
|
-
add_job job, params
|
25
|
+
run Rack::URLMap.new mounts
|
26
|
+
end
|
42
27
|
end
|
28
|
+
end
|
29
|
+
end
|
43
30
|
|
44
|
-
private
|
45
31
|
|
46
|
-
def add_job(job, args={})
|
47
|
-
job_class = Jobs.get_class job
|
48
32
|
|
49
|
-
if !job_class
|
50
|
-
response = {
|
51
|
-
status: 'error',
|
52
|
-
message: 'No such job',
|
53
|
-
job: job,
|
54
|
-
params: args
|
55
|
-
}
|
56
33
|
|
57
|
-
status 404
|
58
|
-
logger.debug "[jobly server] No such job (#{job})"
|
59
|
-
return response.to_json
|
60
|
-
end
|
61
|
-
|
62
|
-
args = args.convert_to_typed
|
63
|
-
if args.empty?
|
64
|
-
job_class.perform_async
|
65
|
-
else
|
66
|
-
job_class.perform_async args
|
67
|
-
end
|
68
|
-
|
69
|
-
response = {
|
70
|
-
status: 'received',
|
71
|
-
job: job,
|
72
|
-
params: args,
|
73
|
-
}
|
74
|
-
|
75
|
-
logger.debug "[jobly server] Job received (#{job})"
|
76
|
-
response.to_json
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
data/lib/jobly/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jobly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
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: 2019-03-
|
11
|
+
date: 2019-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mister_bin
|
@@ -188,6 +188,7 @@ files:
|
|
188
188
|
- README.md
|
189
189
|
- bin/jobly
|
190
190
|
- lib/jobly.rb
|
191
|
+
- lib/jobly/api.rb
|
191
192
|
- lib/jobly/boot.rb
|
192
193
|
- lib/jobly/cli.rb
|
193
194
|
- lib/jobly/commands/base.rb
|