This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn iteration->seq | |
[iteration] | |
(seq | |
(reify java.lang.Iterable | |
(iterator [this] | |
(reify java.util.Iterator | |
(hasNext [this] (.hasNext iteration)) | |
(next [this] (.next iteration)) | |
(remove [this] (.remove iteration))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn logs-seq | |
"Convert a docker-client ^LogStream to a seq of lines." | |
[logs] | |
(let [it (iterator-seq logs) | |
content (map #(.toString (.decode StandardCharsets/UTF_8 (.content ^LogMessage %))) it)] | |
(mapcat #(string/split % #"\n") content))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn logs-seq | |
"Convert a docker-client ^LogStream to a seq of lines." | |
[logs] | |
(let [it (iterator-seq logs) | |
content (map #(.content ^LogMessage %) it) | |
stream (bytes/to-input-stream content) | |
reader (io/reader stream)] | |
(line-seq reader))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn attach-params | |
[] | |
(into-array | |
DockerClient$AttachParameter | |
[DockerClient$AttachParameter/LOGS | |
DockerClient$AttachParameter/STDOUT | |
DockerClient$AttachParameter/STDERR | |
DockerClient$AttachParameter/STREAM])) | |
(defn attach-logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def ^:dynamic *debug* false) | |
(def ^:dynamic *trace* false) | |
(def ^:dynamic *info* false) | |
(def ^:dynamic *warn* false) | |
(def ^:dynamic *error* false) | |
(def log-levels | |
[[:debug #'*debug*] | |
[:trace #'*trace*] | |
[:info #'*info*] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn -main | |
[& args] | |
(try | |
(log/info "start") | |
(let [signal (reify sun.misc.SignalHandler | |
(handle [this signal] | |
(log/info "sisyphus sleeps....")))] | |
(sun.misc.Signal/handle (sun.misc.Signal. "INT") signal) | |
(log/info "signal added") | |
@(promise)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn -main | |
[& args] | |
(try | |
(log/info "sisyphus rises") | |
(let [rabbit (rabbit-connect! {}) | |
consumer (start-consumer! rabbit) | |
signal (Thread. | |
(fn [] | |
(log/info "sisyphus sleeps....") | |
(close! rabbit)))] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn -main | |
[& args] | |
(try | |
(log/info "sisyphus rises") | |
(let [rabbit (rabbit-connect! {}) | |
consumer (start-consumer! rabbit) | |
signal (reify sun.misc.SignalHandler | |
(handle [this signal] | |
(log/info "sisyphus sleeps....") | |
(close! rabbit)))] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn profile | |
[f] | |
(let [start (. System (nanoTime)) | |
result (f) | |
elapsed (/ (double (- (. System (nanoTime)) start)) 1000000.0)] | |
{:elapsed elapsed | |
:result result})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2017/01/04 10:27:02 Found job: job:<jobID:"f0748e22-4f94-4c75-7e4b-13d5ad3ad3e0" task:<name:"root.Transcribe" projectID:"default" inputs:<name:"mount" path:"/mnt" class:"Directory" create:true > inputs:<name:"working_dir" location:"a2289765-ff58-4806-bf8f-99d7716d6322/working_dir" path:"/mnt/working_dir" class:"Directory" > inputs:<name:"job.json" location:"a2289765-ff58-4806-bf8f-99d7716d6322/job.json" path:"/mnt/job.json" class:"File" create:true > outputs:<name:"working_dir" location:"a2289765-ff58-4806-bf8f-99d7716d6322/working_dir" path:"/mnt/working_dir" class:"Directory" > outputs:<name:"command.sh" location:"a2289765-ff58-4806-bf8f-99d7716d6322/command.sh" path:"/mnt/command.sh" class:"File" > outputs:<name:"environment.sh" location:"a2289765-ff58-4806-bf8f-99d7716d6322/environment.sh" path:"/mnt/environment.sh" class:"File" > resources:<volumes:<name:"vol_work" sizeGb:1 mountPoint:"/mnt" > > taskID:"f0748e22-4f94-4c75-7e4b-13d5ad3ad3e0" docker:<imageName:"rabix/tes-command-line:v2" cmd:"/usr/shar |
NewerOlder