This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-26
Channels
- # announcements (6)
- # babashka (29)
- # babashka-sci-dev (2)
- # beginners (129)
- # calva (9)
- # clara (16)
- # cljdoc (49)
- # clojure (125)
- # clojure-bay-area (3)
- # clojure-europe (55)
- # clojure-france (1)
- # clojuredesign-podcast (8)
- # clojurescript (85)
- # conjure (3)
- # core-logic (2)
- # cursive (1)
- # events (1)
- # honeysql (61)
- # jobs-discuss (23)
- # lsp (69)
- # malli (14)
- # nrepl (3)
- # off-topic (16)
- # portal (11)
- # re-frame (8)
- # releases (1)
- # ring (2)
- # shadow-cljs (12)
- # vim (42)
- # xtdb (18)
FYI clj-rss works with babashka, I made a PR with an example and deps.edn https://github.com/yogthos/clj-rss/pull/25 . So you can generate RSS feeds from directories using babashka scripts
quick question, is there any info somewhere on how to process posix signals? SIGTERM in particular?
@roguas In Java you can use use these classes for it:
(:import [sun.misc Signal]
[sun.misc SignalHandler])
They are not exposed by bb to scripts right now, but some of it is available in babashka.signal
: there is one function pipe-signal-received?
We could add more stuff to that namespace and/or expose the sun.misc classes -- but sun.* classes are actually considered implementation detail.
gonna take a look, thanks... supporting SIGTERM seems pretty crucial to me, if you are running scripts as docker containers, this is de facto way to communicate from host os 🙂
I'm ok with exposing these classes, that seems to be the lowest level of friction since the internet has Clojure examples on how to do this stuff
and although they are implementation details, I think it's unlikely they'll ever deprecate these since unless the offer a more "supported" way
big thanks, really impressed 🙂 I think its really a must have if you plan on running inside docker/container, SIGTERM is part of normal lifecycle
well, depends on the workload, but if you have a workload that has some cleanup (say close a connection to db) its good to do that, I am working on agent that would startup another job and this job has capability to susped and dump partial results... most people also do kill -9
to later stackoverflow why the thing broke down/left garbage 🙂
For cleanup, you want to register a Runtime.shutdownHook, that's the preferred way to handle it in Java
Added it, and seems to work:
$ ./bb -e '(sun.misc.Signal/handle (sun.misc.Signal. "INT") (reify sun.misc.SignalHandler (handle [_ _] (prn :hello)))) (Thread/sleep 10000)'
^C:hello
^C:hello
^C:hello
^C:hello
^C:hello
A new binary will appear in #babashka-circleci-builds in the signal
branchMaybe an obvious question, but is sun.misc.Signal actually exposed in the module graph?
Here is some info about that. https://stackoverflow.com/a/60172333/6264
Here is some more explanation: https://blogs.oracle.com/javamagazine/post/a-peek-into-java-17-continuing-the-drive-to-encapsulate-the-java-runtime-internals