Search in sources :

Example 1 with InvestmentMode

use of com.github.robozonky.app.configuration.InvestmentMode in project robozonky by RoboZonky.

the class App method execute.

private static ReturnCode execute(final InvestmentMode mode) {
    App.SHUTDOWN_HOOKS.register(() -> Optional.of((r) -> Scheduler.inBackground().close()));
    Events.fire(new RoboZonkyStartingEvent());
    try {
        ensureLiveness();
        Scheduler.inBackground().submit(new UpdateMonitor(), Duration.ofDays(1));
        App.SHUTDOWN_HOOKS.register(new Management(LIFECYCLE));
        final String sessionName = Events.getSessionInfo().flatMap(SessionInfo::getName).orElse(null);
        App.SHUTDOWN_HOOKS.register(new RoboZonkyStartupNotifier(sessionName));
        return mode.apply(LIFECYCLE);
    } catch (final Throwable t) {
        LOGGER.error("Caught unexpected exception, terminating daemon.", t);
        return ReturnCode.ERROR_UNEXPECTED;
    }
}
Also used : RoboZonkyStartingEvent(com.github.robozonky.api.notifications.RoboZonkyStartingEvent) Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) SystemExitServiceLoader(com.github.robozonky.util.SystemExitServiceLoader) Scheduler(com.github.robozonky.util.Scheduler) SessionInfo(com.github.robozonky.api.notifications.SessionInfo) UpdateMonitor(com.github.robozonky.app.version.UpdateMonitor) CommandLine(com.github.robozonky.app.configuration.CommandLine) Charset(java.nio.charset.Charset) Locale(java.util.Locale) Duration(java.time.Duration) Management(com.github.robozonky.app.management.Management) SystemExitService(com.github.robozonky.util.SystemExitService) Lifecycle(com.github.robozonky.app.runtime.Lifecycle) Optional(java.util.Optional) ReturnCode(com.github.robozonky.api.ReturnCode) InvestmentMode(com.github.robozonky.app.configuration.InvestmentMode) RoboZonkyStartingEvent(com.github.robozonky.api.notifications.RoboZonkyStartingEvent) UpdateMonitor(com.github.robozonky.app.version.UpdateMonitor) Management(com.github.robozonky.app.management.Management)

Aggregations

ReturnCode (com.github.robozonky.api.ReturnCode)1 RoboZonkyStartingEvent (com.github.robozonky.api.notifications.RoboZonkyStartingEvent)1 SessionInfo (com.github.robozonky.api.notifications.SessionInfo)1 CommandLine (com.github.robozonky.app.configuration.CommandLine)1 InvestmentMode (com.github.robozonky.app.configuration.InvestmentMode)1 Management (com.github.robozonky.app.management.Management)1 Lifecycle (com.github.robozonky.app.runtime.Lifecycle)1 UpdateMonitor (com.github.robozonky.app.version.UpdateMonitor)1 Scheduler (com.github.robozonky.util.Scheduler)1 SystemExitService (com.github.robozonky.util.SystemExitService)1 SystemExitServiceLoader (com.github.robozonky.util.SystemExitServiceLoader)1 Charset (java.nio.charset.Charset)1 Duration (java.time.Duration)1 Locale (java.util.Locale)1 Optional (java.util.Optional)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1