Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Oct 16, 2023
1 parent e4c46cb commit 66441c2
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/java/io/cryostat/agent/Agent.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import sun.misc.Signal;
import sun.misc.SignalHandler;

public class Agent implements Consumer<String> {
public class Agent implements Consumer<AgentArgs> {

private static Logger log = LoggerFactory.getLogger(Agent.class);
private static final AtomicBoolean needsCleanup = new AtomicBoolean(true);
Expand Down Expand Up @@ -90,10 +90,13 @@ public static void premain(String args) {

// dynamic attach entry point, Agent is starting after being loaded and attached to a running
// JVM application
// FIXME the 'args' here should be parsed by AgentArgs. Currently it is just assumed that it is
// the positional SmartTriggers syntax argument since that is the only thing it (optionally)
// may be.
public static void agentmain(String args) {
log.trace("agentmain");
Agent agent = new Agent();
Thread t = new Thread(() -> agent.accept(args));
AgentArgs aa = new AgentArgs(String.valueOf(ProcessHandle.current().pid()), args);
Thread t = new Thread(() -> new Agent().accept(aa));
t.setDaemon(true);
t.setName("cryostat-agent-main");
t.start();
Expand Down Expand Up @@ -138,7 +141,7 @@ static URI selfJarLocation() throws URISyntaxException {
}

@Override
public void accept(String smartTriggers) {
public void accept(AgentArgs args) {
log.info("Cryostat Agent starting...");
AgentExitHandler agentExitHandler = null;
try {
Expand Down Expand Up @@ -187,7 +190,7 @@ public void accept(String smartTriggers) {
});
webServer.start();
registration.start();
client.triggerEvaluator().start(smartTriggers);
client.triggerEvaluator().start(args.getSmartTriggers());
log.info("Startup complete");
} catch (Exception e) {
log.error(Agent.class.getSimpleName() + " startup failure", e);
Expand Down

0 comments on commit 66441c2

Please sign in to comment.