CompressLog: Add zstd compression
This commit is contained in:
		| @@ -408,6 +408,7 @@ in | ||||
|         requires = [ "hydra-init.service" ]; | ||||
|         after = [ "hydra-init.service" ]; | ||||
|         restartTriggers = [ hydraConf ]; | ||||
|         path = [ pkgs.zstd ]; | ||||
|         environment = env // { | ||||
|           PGPASSFILE = "${baseDir}/pgpass-queue-runner"; # grrr | ||||
|           HYDRA_DBI = "${env.HYDRA_DBI};application_name=hydra-notify"; | ||||
|   | ||||
| @@ -174,6 +174,9 @@ sub getDrvLogPath { | ||||
|     for ($fn . $bucketed, $fn . $bucketed . ".bz2") { | ||||
|         return $_ if -f $_; | ||||
|     } | ||||
|     for ($fn . $bucketed, $fn . $bucketed . ".zst") { | ||||
|         return $_ if -f $_; | ||||
|     } | ||||
|     return undef; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -9,11 +9,24 @@ use Hydra::Helper::CatalystUtils; | ||||
| sub stepFinished { | ||||
|     my ($self, $step, $logPath) = @_; | ||||
|  | ||||
|     my $doCompress = $self->{config}->{'compress_build_logs'} // "1"; | ||||
|     my $doCompress = $self->{config}->{'compress_build_logs'} // '1'; | ||||
|     my $silent = $self->{config}->{'compress_build_logs_silent'} // '0'; | ||||
|     my $compression = $self->{config}->{'compress_build_logs_compression'} // 'bzip2'; | ||||
|  | ||||
|     if ($doCompress eq "1" && -e $logPath) { | ||||
|         print STDERR "compressing ‘$logPath’...\n"; | ||||
|         system("bzip2", "--force", $logPath); | ||||
|     if (not -e $logPath or $doCompress ne "1") { | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     if ($silent ne '1') { | ||||
|         print STDERR "compressing '$logPath' with $compression...\n"; | ||||
|     } | ||||
|  | ||||
|     if ($compression eq 'bzip2') { | ||||
|         system('bzip2', '--force', $logPath); | ||||
|     } elsif ($compression eq 'zstd') { | ||||
|         system('zstd', '--rm', '--quiet', '-T0', $logPath); | ||||
|     } else { | ||||
|         print STDERR "unknown compression type '$compression'\n"; | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -16,7 +16,10 @@ sub process { | ||||
|  | ||||
|     my $tail = int($c->stash->{tail} // "0"); | ||||
|  | ||||
|     if ($logPath =~ /\.bz2$/) { | ||||
|     if ($logPath =~ /\.zst$/) { | ||||
|         my $doTail = $tail ? "| tail -n '$tail'" : ""; | ||||
|         open($fh, "-|", "zstd -dc < '$logPath' $doTail") or die; | ||||
|     } elsif ($logPath =~ /\.bz2$/) { | ||||
|         my $doTail = $tail ? "| tail -n '$tail'" : ""; | ||||
|         open($fh, "-|", "bzip2 -dc < '$logPath' $doTail") or die; | ||||
|     } else { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user