On Fri, Dec 16, 2016 at 9:26 AM, <[email protected]> wrote:

> I'm trying to run a simple java-example application(which print "hello
> world") under the apps,i built it with CLI by the command below:
>                  ./scripts/build image=java-example,cli
> and then,run it with command:
>                 ./scripts/run.py
>

As Waldek asked, there's a question of whether you really wanted to include
the "cli" in this image. The cli is an interactive shell (not a full
Unix-compatible shell, but something more constrained). If your Java
program is something more substantial than "java-example", it is unlikely
that you actually want to run both it and a shell in parallel - e.g.,
considering that both will write output to the same terminal, and fight
over the keyboard input.

But if you really wanted to include the CLI, I'll continue:


> it successfully print "hello world",but when i input some simple command(
> such as ls,cd ) in the cli,it turns out:
>    ls: Unknown response code: connection refused
> or
>    cd: Unknown response code: connection refused
> only the command 'exit' works.
>
> How does this problem happen and how to sovle it?
>

I would consider this a bug:

As you can see in build/release.x64/cmdline, the command line OSv runs is:

/cli/cli.so&java.so io.osv.isolated.MultiJarLoader -mains /etc/javamains

The intention of "&" was to run those two commands (cli.so and java.so) in
parallel.

The code in loader.cc's do_main_thread() - near its end - runs these
commands, but then waits *only* for the last one, and when it finishes, it
asks httpd to terminate (so we don't wait for it as well).
But because the last command finished fast the first one didn't - we end up
killing httpserver too soon, and the CLI requires this httpserver to be
functional (because the CLI uses the REST API which this httpserver
provides).

I think do_main_thread() needs to be fixed to wait for all non-detached
applications (app->join() all the apps which are not detached), and not
just the last one, before the app->request_termination() loop...
Looks like a very easy thing to fix.

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to