public class Crash extends Object implements Jooby.Module
Connect, monitor or use virtual machine resources via SSH, telnet or HTTP with CRaSH remote shell.
import org.jooby.crash;
{
use(new Crash());
}
That's all you need to get CRaSH up and running!!!
Now is time to see how to connect and interact with the CRaSH shell
You can write additional shell commands using Groovy or Java, see the
CRaSH documentation for
details. CRaSH search for commands in the cmd folder.
Here is a simple ‘hello’ command that could be loaded from cmd/hello.groovy folder:
package commands
import org.crsh.cli.Command
import org.crsh.cli.Usage
import org.crsh.command.InvocationContext
class hello {
@Usage("Say Hello")
@Command
def main(InvocationContext context) {
return "Hello"
}
}
Jooby adds some additional attributes and commands to InvocationContext that you can access from your command:
Registry.Config.
The routes print all the application routes.
The conf tree print the application configuration tree (configuration precedence).
The conf props [path] print all the application properties, sub-tree or a single
property if path argument is present.
The HTTP connector is a simple yet powerful collection of HTTP endpoints where you can run CRaSH command:
{
use(new Crash()
.plugin(HttpShellPlugin.class)
);
}
Try it:
GET /api/shell/thread/ls
OR:
GET /api/shell/thread ls
The connector listen at /api/shell. If you want to mount the connector some
where
else just set the property: crash.httpshell.path.
Just add the crash.connectors.ssh dependency to your project.
Try it:
ssh -p 2000 admin@localhost
Default user and password is: admin. See how to provide a custom
authentication
plugin.
Just add the crash.connectors.telnet dependency to your project.
Try it:
telnet localhost 5000
Checkout complete telnet connector configuration.
Just add the crash.connectors.web dependency to your project.
Try it:
GET /shell
A web shell console will be ready to go at /shell. If you want to mount the
connector some where else just set the property: crash.webshell.path.
| Constructor and Description |
|---|
Crash()
Creates a new
Crash module. |
Crash(ClassLoader loader)
Creates a new
Crash module. |
| Modifier and Type | Method and Description |
|---|---|
com.typesafe.config.Config |
config() |
void |
configure(Env env,
com.typesafe.config.Config conf,
com.google.inject.Binder binder) |
Crash |
plugin(Class<? extends org.crsh.plugin.CRaSHPlugin> plugin)
Add a custom plugin to CRaSH.
|
public Crash(ClassLoader loader)
Crash module.loader - Class loader to use or null.public Crash()
Crash module.public Crash plugin(Class<? extends org.crsh.plugin.CRaSHPlugin> plugin)
plugin - Plugin class.public void configure(Env env, com.typesafe.config.Config conf, com.google.inject.Binder binder)
configure in interface Jooby.Modulepublic com.typesafe.config.Config config()
config in interface Jooby.ModuleCopyright © 2018. All rights reserved.