use of com.walmartlabs.concord.runtime.common.ProcessHeartbeat in project concord by walmartlabs.
the class Main method run.
public void run(RunnerConfiguration runnerCfg, Path baseDir) throws Exception {
log.debug("run -> working directory: {}", baseDir.toAbsolutePath());
long t1 = System.currentTimeMillis();
Path idPath = baseDir.resolve(Constants.Files.INSTANCE_ID_FILE_NAME);
UUID instanceId = readInstanceId(idPath);
long t2 = System.currentTimeMillis();
if (runnerCfg.debug()) {
log.info("Spent {}ms waiting for the payload", (t2 - t1));
}
Map<String, Object> policy = readPolicyRules(baseDir);
if (policy.isEmpty()) {
PolicyEngineHolder.INSTANCE.setEngine(null);
} else {
PolicyEngineHolder.INSTANCE.setEngine(new PolicyEngine(objectMapper.convertValue(policy, PolicyEngineRules.class)));
}
// read the process configuration
Map<String, Object> processCfg = readRequest(baseDir);
processCfg = variablesConverter.convert(baseDir, processCfg);
String sessionToken = getSessionToken(processCfg);
ApiClient apiClient = apiClientFactory.create(ApiClientConfiguration.builder().sessionToken(sessionToken).txId(instanceId).build());
ProcessHeartbeat heartbeat = new ProcessHeartbeat(apiClient, instanceId, runnerCfg.api().maxNoHeartbeatInterval());
heartbeat.start();
ProcessApiClient processApiClient = new ProcessApiClient(runnerCfg, apiClient);
processApiClient.updateStatus(instanceId, runnerCfg.agentId(), ProcessEntry.StatusEnum.RUNNING);
CheckpointManager checkpointManager = new CheckpointManager(instanceId, processApiClient);
long t3 = System.currentTimeMillis();
if (runnerCfg.debug()) {
log.info("Ready to start in {}ms", (t3 - t2));
}
executeProcess(instanceId.toString(), checkpointManager, baseDir, processCfg);
}
use of com.walmartlabs.concord.runtime.common.ProcessHeartbeat in project concord by walmartlabs.
the class Main method main.
public static void main(String[] args) throws Exception {
RunnerConfiguration runnerCfg = readRunnerConfiguration(args);
// create the inject with all dependencies and services available before
// the actual process' working directory is ready. It allows us to load
// all dependencies and have them available in "pre-fork" situations
Injector injector = InjectorFactory.createDefault(runnerCfg);
try {
ProcessConfiguration processCfg = injector.getInstance(ProcessConfiguration.class);
ApiClient apiClient = injector.getInstance(ApiClient.class);
ProcessHeartbeat heartbeat = new ProcessHeartbeat(apiClient, processCfg.instanceId(), runnerCfg.api().maxNoHeartbeatInterval());
heartbeat.start();
Main main = injector.getInstance(Main.class);
main.execute();
System.exit(0);
} catch (MultiException e) {
log.error(e.getMessage());
System.exit(1);
} catch (Throwable t) {
log.error("", t);
System.exit(1);
}
}
Aggregations