postjob 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/postjob/cli/ps.rb +32 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a172df826259a7283f1fd1aa694aed37596f4b0
|
4
|
+
data.tar.gz: 2b054ed712e6cb09047a1612b4cb5e54e3a85468
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dc0cb3dfe11a1c738c023e5bcfd7e652dae744cb53a5ad163cdeb55e1246fcabb0d14fdb10d6d970b485cac8371d1850d39668437df6880ca05437f45275e0e
|
7
|
+
data.tar.gz: 3f10f92136f315c73e39ba9b8f6fa8aed2c977f390aa583b61390a70122c51b01106fae3f1facf76e82eea3b5dcdf7b953676656267bd07f6c1b765f703ccabd
|
data/lib/postjob/cli/ps.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# rubocop:disable Lint/HandleExceptions
|
2
2
|
# rubocop:disable Metrics/MethodLength
|
3
|
+
# rubocop:disable Metrics/ModuleLength
|
4
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
3
5
|
|
4
6
|
module Postjob::CLI
|
5
7
|
private
|
@@ -101,6 +103,36 @@ module Postjob::CLI
|
|
101
103
|
rescue Interrupt
|
102
104
|
end
|
103
105
|
|
106
|
+
# Print the result of a job
|
107
|
+
def ps_result(id)
|
108
|
+
connect_to_database!
|
109
|
+
|
110
|
+
scope = Simple::SQL::Scope.new("SELECT * FROM postjob.postjobs")
|
111
|
+
scope = scope.where("postjobs.id = ANY(?)", parse_ids(id))
|
112
|
+
|
113
|
+
job = Simple::SQL.ask(scope, into: Postjob::Job)
|
114
|
+
raise "Job ##{id}: no such job" unless job
|
115
|
+
|
116
|
+
if job.status == "timeout" || job.status == "failed"
|
117
|
+
# resolve raises exceptions on failing jobs. At this point we'll just tell
|
118
|
+
# the user to be aware of that, and let job.resolve fail below.
|
119
|
+
logger.warn "Job failed. Details below."
|
120
|
+
end
|
121
|
+
|
122
|
+
result = job.resolve
|
123
|
+
|
124
|
+
# Pending jobs don't have a result yet. Just saying..
|
125
|
+
raise "Job ##{id}: job is still pending" if result == :pending
|
126
|
+
|
127
|
+
# Print result. If this is a structure we pretty print, if not we
|
128
|
+
# print verbatim.
|
129
|
+
if result.is_a?(String) || !result.respond_to?(:empty?)
|
130
|
+
puts result
|
131
|
+
else
|
132
|
+
puts JSON.pretty_generate(result)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
104
136
|
# Show all information about this job
|
105
137
|
def ps_show(id, *ids)
|
106
138
|
connect_to_database!
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postjob
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- radiospiel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|