Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

feature request: allow nailgun client to start server #55

Open
jason-s opened this issue May 4, 2015 · 5 comments
Open

feature request: allow nailgun client to start server #55

jason-s opened this issue May 4, 2015 · 5 comments

Comments

@jason-s
Copy link

jason-s commented May 4, 2015

I have "uneducated" customers who could use the ng client from batch files. I would be interested in seeing support for the following use case:

 `ng --config nailgun-config.cfg arg1 arg2 arg3 ...`
  1. reads config file nailgun-config.cfg which looks like a jar-file manifest

    Class-Path: foo bar baz
    Main-Class: com.example.foo.FooClass
    Jvm-Args: [something here]
    Nailgun-Port: 12345

  2. attempts to contact nailgun server on requested port

  3. if attempt succeeds goto step 6

  4. attempt fails: launch server with given class path and JVM args, bound to localhost on Nailgun-Port

  5. if attempt still fails, abort with error

  6. launch com.example.foo.FooClass on server with arg1 arg2 arg3 ... for arguments

This essentially makes the process of running the client the same: the first time it may take a few seconds for the JVM to start up, but after that it should be quick. Then my "uneducated" customers don't need to worry about how to run the server properly.

@sbalabanov-zz
Copy link
Contributor

Closing all issues older than 6 months; please reopen if it is still relevant

@jason-s
Copy link
Author

jason-s commented Jan 29, 2018

please reopen, i can't reopen

@sbalabanov-zz sbalabanov-zz reopened this Jan 29, 2018
@sbalabanov-zz
Copy link
Contributor

Usually people write their own wrappers for that (for example, that is how it is done in Buck) but you are welcome to come up with a PR.

@jvican
Copy link
Contributor

jvican commented Mar 6, 2018

I think it would be interesting if this is solved in the nailgun repository instead of the downstream tools. It would allow us tooling authors to reuse code and avoid writing (and testing) it ourselves.

@skull-squadron
Copy link

skull-squadron commented Jun 19, 2022

@jvican Absolutely great idea. N-downstreams shouldn't reinvent the wheel with layers of scripting and neither should casual DIY builders from source to get something going.

I was working on a replacement nailgun Homebrew formula when I encountered this issue and the Java 18+ Security Manager removal issue. Currently, the original formula is deprecated and at risk for removal.

It should be doable by adjusting ng:

  • Add a new script or executable ng-server to Do The Right Thing™. If someone wants to get adventurous, write it in C99 instead of Bourne shell/Py
  • Add a switch --nailgun-server-autostart true|false and/or environment variable NAILGUN_SERVER_AUTOSTART to ng to enable/disable ng-server auto-spawning (enabled by default to be sensible)
  • Pass ng environment to ng-server. Obviously, only the first run
  • Perhaps leave a note to the user to restart the server if the environment is important, and that the tty will/could be different between ng-server and other instances of ng. Very adventurous to add environment communication between ng and ng-server/NGServer to work more intuitively in more use-cases

For ng-server:

  • optional NAILGUN_SERVER - ip (should default to 127.0.0.1/::1 rather than all interfaces for security reasons)
  • optional NAILGUN_PORT - port (defaults to 2113)
  • optional JAVA_HOME - should be respected to locate {{JAVA_HOME}}/bin/java, but also on macOS it's always a call to java that handles JVM selection via JAVA_HOME
  • required new NAILGUN_SERVER_JAR - abs- or script-relative path of the server .jar to throw into the -cp as it will vary widely on systems
  • ng-server also needs to disown the java process so it backgrounds properly

Prior art on ng servers:

  • Bloop
  • JRuby

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants