all initialized service objects use the same processmanager now, added shutdown hook to deinitialize processmanager and processcontroller objects

This commit is contained in:
Aidan Hahn 2019-05-23 17:24:48 -07:00
parent 3538cac0d8
commit 7b0184cbd3
No known key found for this signature in database
GPG key ID: 327711E983899316
3 changed files with 34 additions and 26 deletions

View file

@ -66,16 +66,21 @@ public class JobServClient {
* writes help information about all commands in the shell to screen
*/
public static void outputHelp() {
System.out.println("... new (command)");
System.out.println("Starts a new process on the server");
System.out.println("... output (pid)");
System.out.println("Garners output from process on server");
System.out.println("... status (pid)");
System.out.println("Returns whether process on server is running");
System.out.println("... return (pid)");
System.out.println("Collects return code from remote process");
System.out.println("... kill (pid)");
System.out.println("Immediately destroys remote process");
System.out.println("... new (command)\n"+
"Starts a new process on the server\n"+
"example: ./client key.pem cert.crt ca.crt localhost 8448 new echo hello world!\n\n"+
"... output (pid)\n"+
"Garners output from process on server\n"+
"example: ./client key.pem cert.crt ca.crt localhost 8448 output 0\n\n"+
"... status (pid)\n"+
"Returns whether process on server is running"+
"example: ./client key.pem cert.crt ca.crt localhost 8448 status 0\n\n"+
"... 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"+
}
/*

View file

@ -32,6 +32,7 @@ public class JobServServer {
private static final Logger logger = Logger.getLogger(JobServServer.class.getName());
private Server server;
private ProcessManager manager;
/*
* Constructor
@ -39,7 +40,7 @@ public class JobServServer {
*/
public JobServServer(SslContext ssl, int port) throws IOException {
this.server = NettyServerBuilder.forPort(port)
.addService(new ShellServerService())
.addService(new ShellServerService(manager))
.sslContext(ssl)
.build()
.start();
@ -58,6 +59,7 @@ public class JobServServer {
@Override
public void run() {
logger.info("Shutting down server");
manager.shutdown();
JobServServer.this.stop();
}
});
@ -122,6 +124,7 @@ public class JobServServer {
return;
}
System.out.println("JobServ Server Initialized! Connect anytime...");
server.blockUntilShutdown();
}
}

View file

@ -21,8 +21,8 @@ class ShellServerService extends ShellServerGrpc.ShellServerImplBase {
* constructor
* initialized ProcessManager
*/
public ShellServerService() {
manager = new ProcessManager();
public ShellServerService(ProcessManager manager) {
this.manager = manager
}
/*