use of com.peterphi.std.guice.common.daemon.GuiceRecurringDaemon in project stdlib by petergeneric.
the class GuiceRestDaemonsServiceImpl method trigger.
@Override
public Response trigger(final String name, final boolean verbose) {
final Optional<GuiceRecurringDaemon> result = registry.getRecurring().stream().filter(d -> StringUtils.equals(name, d.getName())).findFirst();
if (result.isPresent()) {
final GuiceRecurringDaemon daemon = result.get();
if (verbose)
daemon.makeNextRunVerbose();
daemon.trigger();
final String message = "Daemon " + daemon.getName() + " triggered at " + DateTime.now() + " with verbose=" + verbose;
return Response.seeOther(UriBuilder.fromUri(restEndpoint.toString() + "/guice/threads").queryParam("message", message).build()).build();
} else {
throw new IllegalArgumentException("No recurring daemon with name: " + name);
}
}
Aggregations