Fork me on GitHub
#babashka
<
2023-05-03
>
borkdude15:05:21

A nice addition to bb tasks could be:

$ bb run --wait http-server
No such task: --wait
where --wait would implicitly do @(promise) to not exit the process when starting a server? :thinking_face:

👍 5
elken15:05:13

-d for daemon maybe?

borkdude16:05:28

the problem I'm trying to solve is that for some tasks you run a server process and don't want to exit the bb process (so you write @(promise) ) but as soon as you write the @(promise) you can't easily combine it with other tasks. Similarly we have --prn to print results, --wait could be another one such flag. -d : this usually means that your process will run in the background right? which is not the case here, bb will just run in the foreground as usual

elken16:05:17

Ah yes I suppose so, --wait is fine then 🙂

Stephan Renatus17:05:57

would be cool for running portal via bb run

scgilardi16:05:36

might be nice to make it @some.bb.ns/wait-server-exit and offer a function like server-exit to deliver true to that promise. (or task-exit)

lread17:05:07

Before I raise a feature request proposal to solve an interesting problem for https://github.com/babashka/process, maybe it supports this already? Can we redirect stderr to stdout? I see https://docs.oracle.com/javase/8/docs/api/java/lang/ProcessBuilder.html#redirectErrorStream-boolean- which should make this easy peasy if we don't already have an existing way to do this.

borkdude17:05:18

You can try: :err *out* or

user=> (let [pb (p/pb {:out :inherit} "ls non-existing") pb-obj (:pb pb)] (.redirectErrorStream pb-obj true) (p/start pb))
ls: non-existing: No such file or directory

borkdude17:05:01

But you have a proposal to support this?

lread17:05:58

Ya, that's a bit low level maybe? I was thinking maybe :err :redirect-to-out opt on process and shell fns. Or something similar at that higher level.

borkdude17:05:36

Yep, I think that would be good: :err :inherit-out maybe? since I don't think you'll be able to redirect to anything else than what out is when you have :out :inherit?

borkdude17:05:01

can keep bikeshedding about the name a bit

borkdude17:05:08

hm, if I read the Java docstring correctlyl, the stream will be merged, so maybe :err :out works?

borkdude17:05:14

I'll do an experiment

borkdude17:05:49

ah, cool, this works:

user=> (with-out-str (let [pb (p/pb {:out *out*} "ls non-existing") pb-obj (:pb pb)] (.redirectErrorStream pb-obj true) @(p/start pb)))
"ls: non-existing: No such file or directory\n"

borkdude17:05:55

So :err :out seems good

lread17:05:57

Ya, I think that's good for the API. You want an issue/PR?

lread17:05:24

Alrighty, will do!

clojure-spin 2
gdubs20:05:19

Should a 'static' binary still depend on shared libraries? (I'm trying to run babashka-1.3.179-linux-aarch64-static.tar.gz on termux (android).

gdubs20:05:48

non-static binary (`babashka-1.3.179-linux-aarch64.tar.gz`):

gdubs20:05:50

I guess we should rename the download babashka-1.3.179-linux-aarch64-almost-static.tar.gz (added almost 🙂 ).

borkdude20:05:00

the aarch64 binary only depends on libc, but other libs are compiled static

borkdude20:05:07

this is just a graalvm restriction

vlad_poh22:05:35

Whoa you can run bb on android? Nice! When can we get an iOS version? @U04V15CAJ

1
gdubs21:05:10

I got bb running easily enough by installing it from inside an arch linux proot. (`yay -S bb`). Arch linux has a regular libc.

borkdude22:05:55

@U06GMV0B0 you might be interested in #C0260KHN0Q0. - @U7RJTCH6J managed to get SCI (the interpreter in bb) compiling as a graalvm binary and hooked it up with an ios app, so you could evaluate Clojure stuff that way directly on your mobile, even via an nREPL connection You can watch this episode of Apropos Podcast to see it in action: https://apropos-site.vercel.app/episode/54

wow 2
borkdude22:05:49

To run bb "as is" on iOS won't be that useful I think, since iOS is very closed and secure, you can't just access to all of the filesystem like that and then do interesting scripts, like remove all your old photos

😂 2
phronmophobic22:05:19

I'd be happy to answer any questions although it might be easier to follow up in #C0260KHN0Q0