All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sirius.kernel.health.CleanLogsTask Maven / Gradle / Ivy

/*
 * Made with all the love in the world
 * by scireum in Remshalden, Germany
 *
 * Copyright by scireum GmbH
 * http://www.scireum.de - [email protected]
 */

package sirius.kernel.health;

import sirius.kernel.Sirius;
import sirius.kernel.async.Tasks;
import sirius.kernel.di.std.ConfigValue;
import sirius.kernel.di.std.Part;
import sirius.kernel.di.std.Register;
import sirius.kernel.timer.EveryDay;

import java.time.Duration;

/**
 * Automatically deletes old log files.
 */
@Register
public class CleanLogsTask implements EveryDay {

    @Part
    private Tasks tasks;

    @ConfigValue("health.logFileRetention")
    private Duration logFileRetention;

    @Override
    public String getConfigKeyName() {
        return "logs-cleanup";
    }

    @Override
    public void runTimer() throws Exception {
        tasks.defaultExecutor().start(() -> Sirius.getSetup().cleanOldLogFiles(logFileRetention.toMillis()));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy