librelist archives

« back to archive

2.1.3 "lein run &" hangs unless you redirect stdin from a file

2.1.3 "lein run &" hangs unless you redirect stdin from a file

From:
Andy Fingerhut
Date:
2013-05-08 @ 02:54
I had a simple project where "lein run" did a bit of computation and
printing, but did not read from any files.  A simple "Hello, world!"
project exhibits the behavior described below, too.

I wanted to try to run several of them in parallel in the background for
performance testing, so tried "lein run & lein run &" etc., but all of the
processes hung.  Even a single instance "lein run &" put into the
background hangs.  Bringing it to the foreground causes it to finish
running normally.

As a workaround, I found that I could do "lein run < /dev/null &" and it
progresses normally.

Not sure if this is working as designed, a bug, or just a weird quirk that
is expected if you know the Leiningen internals well enough.

Thanks,
Andy

Re: [leiningen] 2.1.3 "lein run &" hangs unless you redirect stdin from a file

From:
Jean Niklas L'orange
Date:
2013-06-15 @ 13:45
Thought I would comment that I have "resolved" this issue.

I've attempted to solve it, but it seems to be impossible as it is the
shell itself which suspends when we request input from stdin. The full
explanation could be found here:
https://github.com/technomancy/leiningen/issues/1173#issuecomment-19496595

In short, what you would have to do is to run `lein run <&- &` or `lein run
</dev/null &`, and it seems unlikely that there's any workaround this.

-- 
Regards,
Jean Niklas L'orange

Re: [leiningen] 2.1.3 "lein run &" hangs unless you redirect stdin from a file

From:
Bruce Adams
Date:
2013-05-08 @ 12:56
Looks like a bug to me. Do you want to open an issue on github?

Simpler commands, such as "lein help &" and "lein classpath &", run fine 
in the background.

You mention doing performance testing. "lein run" isn't a good choice 
for performance testing. I recommend building a standalone jar with 
"lein uberjar", then running the code with "java -jar 
target/myproject-0.1.0-SNAPSHOT-standalone.jar". This works fine in the 
background without needed to redirect standard in.

- Bruce

On 05/07/2013 10:54 PM, Andy Fingerhut wrote:
> I had a simple project where "lein run" did a bit of computation and 
> printing, but did not read from any files.  A simple "Hello, world!" 
> project exhibits the behavior described below, too.
>
> I wanted to try to run several of them in parallel in the background 
> for performance testing, so tried "lein run & lein run &" etc., but 
> all of the processes hung.  Even a single instance "lein run &" put 
> into the background hangs. Bringing it to the foreground causes it to 
> finish running normally.
>
> As a workaround, I found that I could do "lein run < /dev/null &" and 
> it progresses normally.
>
> Not sure if this is working as designed, a bug, or just a weird quirk 
> that is expected if you know the Leiningen internals well enough.
>
> Thanks,
> Andy

Re: [leiningen] 2.1.3 "lein run &" hangs unless you redirect stdin from a file

From:
Jean Niklas L'orange
Date:
2013-05-10 @ 23:13
Hello,

Sorry for a somewhat late reply, this went through my mailbox without me
noticing it. (Thanks Phil for notifying me!)

On 8 May 2013 04:54, Andy Fingerhut <andy.fingerhut@gmail.com> wrote:

> Not sure if this is working as designed, a bug, or just a weird quirk that
> is expected if you know the Leiningen internals well enough.
>

Yes, this is indeed a bug. I've done some quick experimentations and tests,
and put up issue 1173 on Github [1]. I'll do some more research on
potential solutions tomorrow.

Bruce mentioned this, but I'd like to point it out as well: I'd not
recommend people to stress test on `lein run &`, as Leiningen itself runs
on top with a lot of configurations (such as turning down JVM optimizations
to increase startup time, etc).

Another workaround is to do `lein trampoline run &` instead. If you do the
testing inside your app, I believe this should reflect the speed and memory
usage you'll get on the JVM without Leiningen interfering. It will still
contain the startup time from Leiningen though, so be aware of that.

[1]: https://github.com/technomancy/leiningen/issues/1173

-- 
Regards,
Jean Niklas L'orange