Fork me on GitHub

Any advice for using bb tasks to run my backend server? I saw this old and wonder if anything has changed since then. I have a task that launches my server now. I'd like to run it in the background, have the ability to monitor and kill it, and send the logs to some text files.


Can you give more context about what is currently missing in bb? I don't understand the question


Sure. It's probably not something missing from bb but just a gap in my understanding. • I can launch the background process using process. What is the best way to kill it at that point? Find the PID and kill it as usual, or is there a more idiomatic approach? • Is there something in the API that I should use to redirect stdout/stderr to files, or is it just including the usual &> foo.log as part of the process command? Nevermind, this looks like something I'd do with process's :out :append, :out-file ..., :err-file ....


@UPWHQK562 you can kill a process by calling destroy on it


But it's a server process that should remain up indefinitely. So once I start it with bb server:run, I'm no longer controlling it with Clojure, right?


it depends, what you are doing in your scripts


Okay @borkdude, I think my questions might just be too general. I'll keep experimenting with it. Thanks for your time.


And now edamame is exposed in babashka on master as well.

🎉 5

Hi there, I am trying neil for the first time and did this:

clojure -Ttools install io.github.babashka/neil '{:git/tag "v0.0.28"}' :as neil
And then
clojure -Ttools list
TOOL   LIB                            TYPE  VERSION
neil   io.github.babashka/neil        :git  v0.0.28
tools  io.github.clojure/  :git  v0.2.0
but this does not work
clojure -Tneil dep search "babashka.nrepl"
Function not found: babashka.neil.api/dep
Am I missing something?


@richiardiandrea If you are using babashka, then I recommend installing the bb script rather than using it as a clj tool


@borkdude yeah we can't do that at the moment - not every dev machine has got babashka (it's not a "required" dev tool)


Hey @richiardiandrea I deprecated the tools usage now. Just use the -m main entrypoint. It doesn't make sense to me to maintain two different entrypoints. So going forward, I recommend using this: And there will never be any incompatibilities


Ok sounds good, unfortunately this means for us no babashska for now but I totally understand


@richiardiandrea I don't understand your reasoning


Oh wait, sorry yeah I just realized there is no dependency on the babashka cli


no, but even if there was, why would that be a reason for not using babashka? like: we would use babashka, but now we're not. eh, why? :)


you can use neil from bb and clojure, but the command line interface is the same, that was the point I was trying to make


Oh I see what you are saying. Basically in our case we are not "using it" officially yet for scripts but I am trying to push for it. Neil was an attempt to automate a couple of tasks but because not every dev machine has got bb we wanted to use the Clojure CLI


I hope this makes sense even if it doesn't too much to me lol 😄


yes, tl;dr, you can use the clojure CLI, you don't need the bb binary to run neil :)

❤️ 1

just read the link I sent and it should explain itself, feel free to bother me if it doesn't


yep I just did and I will try it out


the clj tool hasn't been updated, PRs welcome


So, we've added a generic :pre-start-fn to babashka process, which thus also works in shell :

{:tasks {:init (defn print-command [{:keys [cmd]}]
                 (apply println cmd))

         hi (shell {:pre-start-fn print-command} "echo hi")}}

$ bb hi
echo hi
Should we do anything else to make printing the command in shell "easier" or is this sufficient?

Daniel Jomphe17:05:06

Sorry to post a chunk of code but we might use :pre-start-fn sometimes instead of relying on this big global thing here that does that:


Awesome, so from your perspective: no?

Daniel Jomphe17:05:14

Haha you caught me! Exactly, this would be sufficient for our current use, for sure!! 🎉


Babashka-built clojure official Docker images are now live on Docker Hub! 🎉 babashka docker

🎉 7

Do you have a link to the code for those curious?


The best thing is the bb.edn addition is really all I had to do! There's probably more changes to make down the road (towards what it would look like if we'd started with babashka), but it's very cool that a big wad of JVM Clojure is (often) that easy to babashka-fy!


Thanks for sharing! :)

👍 2

does the image includes babashka, or babashka is just being used to build the image?


just the latter (for now)

👍 1

still thinking about whether / how to do an official babashka image, and if one is even needed when the excellent babashka/babashka images already exist


I'm thinking it could be useful to have it right away on the image, but not sure since babashka updates so often, and is also so easy to install


bb is also available in circle's clojure image :)

👍 1

yeah, and it's also often all you need (i.e. you don't need any of the other clojure stuff; jvm, jre, lein, clojure cli, boot, etc.). and currently the official clojure images are all kind of based on the notion that you need some of those things. 🙂 but I'm happy to rethink it if it makes sense at some point.


there's also clojuredart that might need an official image at some point, so there's potentially a bigger rethink coming anyway...


I could imagine perhaps we start by including bb in our latest image, b/c that's already kind of the kitchen sink, every-battery-is-included image




@borkdude what do you think? do you see a role for an official clojure babashka image? or would that feel needlessly duplicative?


I don't really have a strong opinion

👍 1

yeah, I don't either haha


me neither, but a light opinion that would be nice to have it there already 🫠


@U066U8JQJ as in, already installed in all of the official images (or some logical subset of them)?


then I dunno, haha


fair enough. I get it, I want babashka in all the places too 😆. but some users of the official images want them as tiny as possible. so we have to strike a balance.


and of course you only hear from the folks that want to add things until you add them... and then you hear from those other folks. a lot. 😅


in this consideration, how big is babashka? its big enough for people to note/care about?


for me: no. it's easily worth it. for those who will complain at me: yes, everything they don't use is too big haha


another possibility I would entertain is (in part because the babashka/babashka image is so minimal; no java, no clojure cli, etc.) to release variants of the tools-deps images that also add babashka. for those who want both sets of tools / runtime environments. for e.g. those who use bb as dev tooling ala make.