[pve-devel] [PATCH manager 5/7] pvescheduler: run jobs from jobs.cfg
Dominik Csapak
d.csapak at proxmox.com
Thu Oct 7 10:27:25 CEST 2021
PVE/Jobs is responsible to decide if the job must run (e.g. with a
schedule)
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
PVE/Service/pvescheduler.pm | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/PVE/Service/pvescheduler.pm b/PVE/Service/pvescheduler.pm
index ce55c45a..81f6b089 100644
--- 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);
@@ -39,19 +40,33 @@ sub run {
my $logfunc = sub { syslog('info', $_[0]) };
- 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, $logfunc, 0, 1);
+ $sub->();
POSIX::_exit(0);
}
$jobs->{$child} = 1;
};
+ my $run_jobs = sub {
+
+ $fork->(sub {
+ PVE::API2::Replication::run_jobs(undef, $logfunc, 0, 1);
+ });
+
+ $fork->(sub {
+ PVE::Jobs::run_jobs();
+ });
+ };
+
+ PVE::Jobs::setup_dirs();
+
# try to run near minute boundaries, makes more sense to the user as he
# configures jobs with minute precision
my ($current_seconds) = localtime;
--
2.30.2
More information about the pve-devel
mailing list