use Gruntmaster::Daemon::Constants qw/ERR/;
use Gruntmaster::Daemon::Format qw/mkrun/;
use Gruntmaster::Page qw/generate/;
-use Gruntmaster::Data qw/job_inmeta job_problem problem_meta set_job_daemon set_job_result set_job_result_text set_job_results/;
+use Gruntmaster::Data qw/job_inmeta job_problem problem_meta set_job_daemon set_job_result set_job_result_text set_job_results SUBSCRIBE WAIT_FOR_MESSAGES/;
-use Cwd qw/cwd/;
use File::Basename qw/fileparse/;
use File::Slurp qw/write_file/;
use File::Spec::Functions qw/devnull/;
use File::Temp qw/tempdir/;
use IO::File;
use IPC::Open3 qw/open3/;
-use Redis;
use Sys::Hostname qw/hostname/;
use Time::HiRes qw/time/;
use Try::Tiny;
}
}
-my $tempdir;
-
sub process{
my $job = shift;
- my $rootdir = cwd;
- chdir $tempdir;
my @results;
my @full_results = ();
set_job_result_text $job, $meta->{result_text};
set_job_results $job, \@full_results if scalar @full_results;
- chdir $rootdir;
my $log = $meta->{contest} ? "ct/$meta->{contest}/log" : 'log';
write_file "$log/src/$job." . Gruntmaster::Page::Log::FORMAT_EXTENSION->{$meta->{files}{prog}{format}}, $meta->{files}{prog}{content};
generate "$log/job/$job.html";
sub run{
Log::Log4perl->init('log.conf');
get_logger->info("gruntmasterd $VERSION started");
- $tempdir = tempdir 'gruntmasterd.XXXX', CLEANUP => 1, TMPDIR => 1;
- my $redis = Redis->new;
- $redis->subscribe('jobs', \&got_job);
- $redis->wait_for_messages(0) while 1
+ chdir tempdir 'gruntmasterd.XXXX', CLEANUP => 1, TMPDIR => 1;
+ SUBSCRIBE jobs => \&got_job;
+ WAIT_FOR_MESSAGES 86400 while 1
}
1;