all initialized service objects use the same processmanager now, added shutdown hook to deinitialize processmanager and processcontroller objects
This commit is contained in:
parent
3538cac0d8
commit
7b0184cbd3
3 changed files with 34 additions and 26 deletions
|
|
@ -66,16 +66,21 @@ public class JobServClient {
|
||||||
* writes help information about all commands in the shell to screen
|
* writes help information about all commands in the shell to screen
|
||||||
*/
|
*/
|
||||||
public static void outputHelp() {
|
public static void outputHelp() {
|
||||||
System.out.println("... new (command)");
|
System.out.println("... new (command)\n"+
|
||||||
System.out.println("Starts a new process on the server");
|
"Starts a new process on the server\n"+
|
||||||
System.out.println("... output (pid)");
|
"example: ./client key.pem cert.crt ca.crt localhost 8448 new echo hello world!\n\n"+
|
||||||
System.out.println("Garners output from process on server");
|
"... output (pid)\n"+
|
||||||
System.out.println("... status (pid)");
|
"Garners output from process on server\n"+
|
||||||
System.out.println("Returns whether process on server is running");
|
"example: ./client key.pem cert.crt ca.crt localhost 8448 output 0\n\n"+
|
||||||
System.out.println("... return (pid)");
|
"... status (pid)\n"+
|
||||||
System.out.println("Collects return code from remote process");
|
"Returns whether process on server is running"+
|
||||||
System.out.println("... kill (pid)");
|
"example: ./client key.pem cert.crt ca.crt localhost 8448 status 0\n\n"+
|
||||||
System.out.println("Immediately destroys remote process");
|
"... return (pid)\n"+
|
||||||
|
"Collects return code from remote process\n"+
|
||||||
|
"example: ./client key.pem cert.crt ca.crt localhost 8448 return 0\n\n"+
|
||||||
|
"... kill (pid)"+
|
||||||
|
"Immediately destroys remote process"+
|
||||||
|
"example: ./client key.pem cert.crt ca.crt localhost 8448 kill 0\n\n"+
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ public class JobServServer {
|
||||||
private static final Logger logger = Logger.getLogger(JobServServer.class.getName());
|
private static final Logger logger = Logger.getLogger(JobServServer.class.getName());
|
||||||
|
|
||||||
private Server server;
|
private Server server;
|
||||||
|
private ProcessManager manager;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Constructor
|
* Constructor
|
||||||
|
|
@ -39,7 +40,7 @@ public class JobServServer {
|
||||||
*/
|
*/
|
||||||
public JobServServer(SslContext ssl, int port) throws IOException {
|
public JobServServer(SslContext ssl, int port) throws IOException {
|
||||||
this.server = NettyServerBuilder.forPort(port)
|
this.server = NettyServerBuilder.forPort(port)
|
||||||
.addService(new ShellServerService())
|
.addService(new ShellServerService(manager))
|
||||||
.sslContext(ssl)
|
.sslContext(ssl)
|
||||||
.build()
|
.build()
|
||||||
.start();
|
.start();
|
||||||
|
|
@ -58,6 +59,7 @@ public class JobServServer {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
logger.info("Shutting down server");
|
logger.info("Shutting down server");
|
||||||
|
manager.shutdown();
|
||||||
JobServServer.this.stop();
|
JobServServer.this.stop();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -122,6 +124,7 @@ public class JobServServer {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println("JobServ Server Initialized! Connect anytime...");
|
||||||
server.blockUntilShutdown();
|
server.blockUntilShutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ class ShellServerService extends ShellServerGrpc.ShellServerImplBase {
|
||||||
* constructor
|
* constructor
|
||||||
* initialized ProcessManager
|
* initialized ProcessManager
|
||||||
*/
|
*/
|
||||||
public ShellServerService() {
|
public ShellServerService(ProcessManager manager) {
|
||||||
manager = new ProcessManager();
|
this.manager = manager
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue