From fa7d54564ad9519a041d9810bedaa9ff22d5c6c3 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Mon, 8 Nov 2021 14:07:55 +0100 Subject: [PATCH] pvescheduler: run jobs from jobs.cfg PVE/Jobs is responsible to decide if the job must run (e.g. with a schedule) Signed-off-by: Dominik Csapak --- PVE/Service/pvescheduler.pm | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/PVE/Service/pvescheduler.pm b/PVE/Service/pvescheduler.pm index 96d84e20..a8d548fb 100755 --- a/PVE/Service/pvescheduler.pm +++ b/PVE/Service/pvescheduler.pm @@ -6,6 +6,7 @@ use warnings; use POSIX qw(WNOHANG); use PVE::SafeSyslog; use PVE::API2::Replication; +use PVE::Jobs; use PVE::Daemon; use base qw(PVE::Daemon); @@ -51,19 +52,31 @@ sub run { $old_sig_chld->(@_) if $old_sig_chld; }; - my $run_jobs = sub { + my $fork = sub { + my ($sub) = @_; my $child = fork(); if (!defined($child)) { die "fork failed: $!\n"; } elsif ($child == 0) { $self->after_fork_cleanup(); - PVE::API2::Replication::run_jobs(undef, sub {}, 0, 1); + $sub->(); POSIX::_exit(0); } $jobs->{$child} = 1; }; + my $run_jobs = sub { + + $fork->(sub { + PVE::API2::Replication::run_jobs(undef, sub {}, 0, 1); + }); + + $fork->(sub { + PVE::Jobs::run_jobs(); + }); + }; + PVE::Jobs::setup_dirs(); for (my $count = 1000;;$count++) {