Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ public class SingularityExecutorConfiguration extends BaseRunnerConfiguration {
@JsonProperty
private String logrotateExtrasDateformat = "%Y%m%d";

@JsonProperty
private boolean ignoreLogrotateOutput = false;

@NotNull
@JsonProperty
private LogrotateCompressionSettings logrotateCompressionSettings = LogrotateCompressionSettings.empty();
Expand Down Expand Up @@ -360,6 +363,14 @@ public String getLogrotateExtrasDateformat() {
return logrotateExtrasDateformat;
}

public boolean isIgnoreLogrotateOutput() {
return ignoreLogrotateOutput;
}

public void setIgnoreLogrotateOutput(boolean ignoreLogrotateOutput) {
this.ignoreLogrotateOutput = ignoreLogrotateOutput;
}

public int getTailLogLinesToSave() {
return tailLogLinesToSave;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ public class LogrotateCronTemplateContext {
private final String logrotateCommand;
private final String logrotateStateFile;
private final String logrotateConfig;
private final String outputRedirect;

public LogrotateCronTemplateContext(SingularityExecutorConfiguration configuration, SingularityExecutorTaskDefinition taskDefinition, SingularityExecutorLogrotateFrequency logrotateFrequency) {
this.logrotateCommand = configuration.getLogrotateCommand();
this.logrotateStateFile = taskDefinition.getLogrotateStateFilePath().toString();
this.logrotateConfig = Paths.get(configuration.getLogrotateHourlyConfDirectory()).resolve(taskDefinition.getTaskId()).toString();
this.cronSchedule = logrotateFrequency.getCronSchedule().get();
this.outputRedirect = configuration.isIgnoreLogrotateOutput() ? "> /dev/null 2>&1" : "";
}

public String getLogrotateCommand() {
Expand All @@ -34,4 +36,8 @@ public String getLogrotateConfig() {
public String getCronSchedule() {
return cronSchedule;
}

public String getOutputRedirect() {
return outputRedirect;
}
}
2 changes: 1 addition & 1 deletion SingularityExecutor/src/main/resources/logrotate.cron.hbs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{{ cronSchedule }}} root {{{ logrotateCommand }}} -f -s {{{ logrotateStateFile }}} {{{ logrotateConfig }}}
{{{ cronSchedule }}} root {{{ logrotateCommand }}} -f -s {{{ logrotateStateFile }}} {{{ logrotateConfig }}} {{{ outputRedirect }}}