Compare commits
1 commit
master
...
daemon-exe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f4f1d9e945 |
3 changed files with 21 additions and 5 deletions
|
|
@ -9,7 +9,6 @@ A preview of the next release can be installed from
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
- [#1818](https://github.com/babashka/babashka/issues/1818): wrong argument order in `clojure.java.io/resource` implementation
|
|
||||||
- Add `java.text.BreakIterator`
|
- Add `java.text.BreakIterator`
|
||||||
- Bump `fs` to `0.5.25`
|
- Bump `fs` to `0.5.25`
|
||||||
- Bump `jsoup` to `1.20.1`
|
- Bump `jsoup` to `1.20.1`
|
||||||
|
|
|
||||||
|
|
@ -84,8 +84,8 @@
|
||||||
cp)))
|
cp)))
|
||||||
|
|
||||||
(defn resource
|
(defn resource
|
||||||
(^URL [path] (resource path @the-url-loader))
|
(^URL [path] (resource @the-url-loader path))
|
||||||
(^URL [path loader]
|
(^URL [loader path]
|
||||||
(if (str/starts-with? path "/") nil ;; non-relative paths always return nil
|
(if (str/starts-with? path "/") nil ;; non-relative paths always return nil
|
||||||
(getResource loader [path] true))))
|
(getResource loader [path] true))))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1190,7 +1190,7 @@ Use bb run --help to show this help output.
|
||||||
(println "[babashka] WARNING: config file does not exist:" config))
|
(println "[babashka] WARNING: config file does not exist:" config))
|
||||||
nil))
|
nil))
|
||||||
jar (let [jar (resolve-symbolic-link jar)]
|
jar (let [jar (resolve-symbolic-link jar)]
|
||||||
(some->> [jar] cp/new-loader (cp/resource "META-INF/bb.edn") .toString))
|
(some-> [jar] cp/new-loader (cp/resource "META-INF/bb.edn") .toString))
|
||||||
:else (if (and file (fs/exists? file))
|
:else (if (and file (fs/exists? file))
|
||||||
;; file relative to bb.edn
|
;; file relative to bb.edn
|
||||||
(let [file (abs-path file) ;; follow symlink
|
(let [file (abs-path file) ;; follow symlink
|
||||||
|
|
@ -1250,10 +1250,26 @@ Use bb run --help to show this help output.
|
||||||
@v#)
|
@v#)
|
||||||
`(apply main ~args)))
|
`(apply main ~args)))
|
||||||
|
|
||||||
|
(defn- set-daemon-agent-executor
|
||||||
|
"Set Clojure's send-off agent executor (also affects futures). This is almost
|
||||||
|
an exact rewrite of the Clojure's executor, but the Threads are created as
|
||||||
|
daemons."
|
||||||
|
[]
|
||||||
|
(let [thread-counter (atom 0)
|
||||||
|
thread-factory (reify java.util.concurrent.ThreadFactory
|
||||||
|
(newThread [_ runnable]
|
||||||
|
(doto (Thread. runnable)
|
||||||
|
(.setDaemon true) ;; DIFFERENT
|
||||||
|
(.setName (format "CLI-agent-send-off-pool-%d"
|
||||||
|
(first (swap-vals! thread-counter inc)))))))
|
||||||
|
executor (java.util.concurrent.Executors/newCachedThreadPool thread-factory)]
|
||||||
|
(set-agent-send-off-executor! executor)))
|
||||||
|
|
||||||
(defn -main
|
(defn -main
|
||||||
[& args]
|
[& args]
|
||||||
(handle-pipe!)
|
(handle-pipe!)
|
||||||
(handle-sigint!)
|
(handle-sigint!)
|
||||||
|
(set-daemon-agent-executor)
|
||||||
(if-let [dev-opts (System/getenv "BABASHKA_DEV")]
|
(if-let [dev-opts (System/getenv "BABASHKA_DEV")]
|
||||||
(let [{:keys [:n]} (if (= "true" dev-opts) {:n 1}
|
(let [{:keys [:n]} (if (= "true" dev-opts) {:n 1}
|
||||||
(edn/read-string dev-opts))
|
(edn/read-string dev-opts))
|
||||||
|
|
@ -1265,7 +1281,8 @@ Use bb run --help to show this help output.
|
||||||
(binding [*out* *err*]
|
(binding [*out* *err*]
|
||||||
(println "ran" n "times"))))))
|
(println "ran" n "times"))))))
|
||||||
(let [exit-code (run args)]
|
(let [exit-code (run args)]
|
||||||
(System/exit exit-code))))
|
(when-not (zero? exit-code)
|
||||||
|
(System/exit exit-code)))))
|
||||||
|
|
||||||
(sci/alter-var-root main-var (constantly -main))
|
(sci/alter-var-root main-var (constantly -main))
|
||||||
;;;; Scratch
|
;;;; Scratch
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue