This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-15
Channels
- # aleph (2)
- # babashka (35)
- # beginners (31)
- # biff (6)
- # calva (6)
- # cider (5)
- # clojure (61)
- # clojure-android (1)
- # clojure-dev (12)
- # clojure-europe (22)
- # clojure-norway (7)
- # clojure-uk (4)
- # clojurescript (19)
- # datomic (5)
- # events (3)
- # fulcro (15)
- # graalvm (41)
- # guix (2)
- # honeysql (2)
- # hoplon (8)
- # hyperfiddle (10)
- # jobs (1)
- # off-topic (29)
- # overtone (5)
- # podcasts-discuss (1)
- # remote-jobs (1)
- # sci (30)
- # shadow-cljs (186)
- # specter (2)
- # squint (22)
Hi everyone! I'm using babashka process in a CLI of mine and I'd like to know if there's a way to detach the process from the current shell so I can run commands that while to finish in background. I tried some solutions like append &!
at the end of my command but it didn't work. For now I'm just appending "&!" to my CLI calls from terminal, but I'd like to do that through code.
Just to clarify: do you want to start the process and just let it run without checking if it's alive? Or do you want to spawn a process, monitor it in a background while doing other work?
if youre trying to start a process which is forked off you can use https://github.com/babashka/process/blob/master/API.md#babashka.process/process which returns a running Process object whcih can be interacted with. Also FYI, the &
at the end is a bash/shell syntax, OS specific and not related to the Process itself.
@U0JEFEZH6 @U7ERLH6JX
I want to spawn the process and let it run. I'm using process
but i don't want to block my current session.
For now, I'm running my CLI like my-cli sub command &!
. But I want to run it as my-cli sub command
but the process I spawn with process
just die when babashka "quits"
@U0132G7Q29X this works:
(require '[babashka.process :as p])
;; fork off the ls process here. non blocking
(def ls (p/process "ls" "-alh"))
; ... do other stuff here
you can have some long running process there
I think he wants to keep the process running when bb quits so another examples would be needed to illustrate that
right
That's it @U04V15CAJ!
I'll try to explain my use case:
1- In my project I have some shellscripts that execute a lot of stuff, like download huge files
2- The CLI i've built with babashka prepare a lot of stuff to call this script properly (e.g. envars, config files, validations, etc)
3- Call the shellscript through babashka.process/process
I wanted to execute step 3 and keep it running even when bb quits
I don't know if this is helpful somehow.
Ty for your help
@U0132G7Q29X As you can see in this example, child bb keeps running while the parent bb quits after two seconds.
bb -e '(babashka.process/process {:inherit true} "bb -e \"(while true (Thread/sleep 1000) (prn :hello))\"") (Thread/sleep 2000)'
Ty @U04V15CAJ I'll try it out asap
Has anyone done a static site generator using Babashka?
Amazing
Several of my personal and project sites use bb
too 🙂
the “landing page” for my home server is generated from bb and huff. It lists 15ish categorized links to services I run here at home
Anyone else look at templating languages and marvel at how inelegant they are compared to hiccup-life?
I built my current website using Eleventy about 3-4 months ago. I opened it up to change some to change something a couple of days ago and couldn’t figure it out. 😆
I seem to remember there was a library for doing fancy cli tools is that for babashka or was it nbb or something ? can't remember the name 😕
@U02DXJUS5JA There is https://github.com/babashka/cli as a built-in option
yeah I am thinking of something else todo progress bars or live reactive updating on atom changes or maybe i imagined it 😛
ah you mean nbb + reagent + ink: https://github.com/babashka/nbb#reagent
ink was the library I was trying to remember but I will look at both options, cheers
@U0DSU64Q1 I do not have ssh Banner setup on any of my SSH servers. Thus I don't see this. I will try setting up a banner and see if I can replicate, and if so open a ticket.
@U1QQJJK89 thank you!