summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Bugzilla/DaemonControl.pm68
-rw-r--r--docker-compose.yml14
-rwxr-xr-xscripts/entrypoint.pl7
3 files changed, 73 insertions, 16 deletions
diff --git a/Bugzilla/DaemonControl.pm b/Bugzilla/DaemonControl.pm
index 510886dba..6586cc01b 100644
--- a/Bugzilla/DaemonControl.pm
+++ b/Bugzilla/DaemonControl.pm
@@ -28,7 +28,8 @@ use POSIX qw(setsid WEXITSTATUS);
use base qw(Exporter);
our @EXPORT_OK = qw(
- run_httpd run_cereal run_cereal_and_httpd
+ run_httpd run_cereal run_jobqueue
+ run_cereal_and_httpd run_cereal_and_jobqueue
catch_signal on_finish on_exception
assert_httpd assert_database assert_selenium
);
@@ -39,10 +40,12 @@ our %EXPORT_TAGS = (
utils => [qw(catch_signal on_exception on_finish)],
);
-use constant CEREAL_BIN => realpath(catfile( bz_locations->{cgi_path}, 'scripts', 'cereal.pl'));
-
-use constant HTTPD_BIN => '/usr/sbin/httpd';
-use constant HTTPD_CONFIG => realpath(catfile( bz_locations->{confdir}, 'httpd.conf' ));
+use constant {
+ JOBQUEUE_BIN => realpath( catfile( bz_locations->{cgi_path}, 'jobqueue.pl' ) ),
+ CEREAL_BIN => realpath( catfile( bz_locations->{cgi_path}, 'scripts', 'cereal.pl' ) ),
+ HTTPD_BIN => '/usr/sbin/httpd',
+ HTTPD_CONFIG => realpath( catfile( bz_locations->{confdir}, 'httpd.conf' ) ),
+};
sub catch_signal {
my ($name, @done) = @_;
@@ -75,7 +78,7 @@ sub run_cereal {
my $cereal = IO::Async::Process->new(
command => [CEREAL_BIN],
on_finish => on_finish($exit_f),
- on_exception => on_exception( "cereal", $exit_f ),
+ on_exception => on_exception( 'cereal', $exit_f ),
);
$exit_f->on_cancel( sub { $cereal->kill('TERM') } );
$loop->add($cereal);
@@ -85,15 +88,18 @@ sub run_cereal {
sub run_httpd {
my (@args) = @_;
- my $loop = IO::Async::Loop->new;
+ my $loop = IO::Async::Loop->new;
my $exit_f = $loop->new_future;
my $httpd = IO::Async::Process->new(
code => sub {
+
# we have to setsid() to make a new process group
# or else apache will kill its parent.
setsid();
- exec HTTPD_BIN, '-DFOREGROUND', '-f' => HTTPD_CONFIG, @args;
+ my @command = ( HTTPD_BIN, '-DFOREGROUND', '-f' => HTTPD_CONFIG, @args );
+ exec @command
+ or die "failed to exec $command[0] $!";
},
on_finish => on_finish($exit_f),
on_exception => on_exception( 'httpd', $exit_f ),
@@ -104,21 +110,52 @@ sub run_httpd {
return $exit_f;
}
+sub run_jobqueue {
+ my (@args) = @_;
+
+ my $loop = IO::Async::Loop->new;
+ my $exit_f = $loop->new_future;
+ my $jobqueue = IO::Async::Process->new(
+ command => [ JOBQUEUE_BIN, 'start', '-f', '-d', @args ],
+ on_finish => on_finish($exit_f),
+ on_exception => on_exception( 'httpd', $exit_f ),
+ );
+ $exit_f->on_cancel( sub { $jobqueue->kill('TERM') } );
+ $loop->add($jobqueue);
+
+ return $exit_f;
+}
+
+sub run_cereal_and_jobqueue {
+ my (@jobqueue_args) = @_;
+
+ my $signal_f = catch_signal('TERM', 0);
+ my $cereal_exit_f = run_cereal();
+
+ return assert_cereal()->then(
+ sub {
+ my $jobqueue_exit_f = run_jobqueue(@jobqueue_args);
+ return Future->wait_any($cereal_exit_f, $jobqueue_exit_f, $signal_f);
+ }
+ );
+}
+
sub run_cereal_and_httpd {
my @httpd_args = @_;
- push @httpd_args, '-DNETCAT_LOGS';
- my $signal_f = catch_signal("TERM", 0);
+ my $signal_f = catch_signal('TERM', 0);
my $cereal_exit_f = run_cereal();
return assert_cereal()->then(
sub {
+ push @httpd_args, '-DNETCAT_LOGS';
+
my $lc = Bugzilla::Install::Localconfig::read_localconfig();
if ( ($lc->{inbound_proxies} // '') eq '*' && $lc->{urlbase} =~ /^https/) {
push @httpd_args, '-DHTTPS';
}
elsif ($lc->{urlbase} =~ /^https/) {
- WARN("HTTPS urlbase but inbound_proxies is not '*'");
+ WARN('HTTPS urlbase but inbound_proxies is not "*"');
}
my $httpd_exit_f = run_httpd(@httpd_args);
@@ -140,24 +177,23 @@ sub assert_httpd {
my $f = shift;
( $f->get =~ /^httpd OK/ );
};
- my $timeout = $loop->timeout_future(after => 20)->else_fail("assert_httpd timeout");
+ my $timeout = $loop->timeout_future(after => 20)->else_fail('assert_httpd timeout');
return Future->wait_any($repeat, $timeout);
}
-
sub assert_selenium {
my ($host, $port) = @_;
$host //= 'localhost';
$port //= 4444;
- return assert_connect($host, $port, "assert_selenium");
+ return assert_connect($host, $port, 'assert_selenium');
}
sub assert_cereal {
return assert_connect(
'localhost',
$ENV{LOGGING_PORT} // 5880,
- "assert_cereal"
+ 'assert_cereal'
);
}
@@ -199,7 +235,7 @@ sub assert_database {
);
} until => sub { defined shift->get };
- my $timeout = $loop->timeout_future( after => 20 )->else_fail("assert_database timeout");
+ my $timeout = $loop->timeout_future( after => 20 )->else_fail('assert_database timeout');
my $any_f = Future->wait_any( $repeat, $timeout );
return $any_f->transform(
done => sub { return },
diff --git a/docker-compose.yml b/docker-compose.yml
index e04e9c712..5dfb6fad4 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -33,6 +33,20 @@ services:
- bmo-db.vm
- memcached
+ bmo-jobqueue.vm:
+ build: *bmo_build
+ command: jobqueue
+ volumes:
+ - bmo-data-dir:/app/data
+ tmpfs:
+ - /tmp
+ - /run
+ environment: *bmo_env
+ restart: always
+ depends_on:
+ - bmo-db.vm
+ - memcached
+
bmo-db.vm:
image: mozillabteam/bmo-mysql:5.6
volumes:
diff --git a/scripts/entrypoint.pl b/scripts/entrypoint.pl
index 23578e257..5c981c5c2 100755
--- a/scripts/entrypoint.pl
+++ b/scripts/entrypoint.pl
@@ -10,6 +10,7 @@ use Bugzilla::Install::Util qw(install_string);
use Bugzilla::Test::Util qw(create_user);
use Bugzilla::DaemonControl qw(
run_cereal_and_httpd
+ run_cereal_and_jobqueue
assert_httpd assert_database assert_selenium
on_finish on_exception
);
@@ -89,6 +90,12 @@ sub cmd_httpd {
exit $httpd_exit_f->get();
}
+sub cmd_jobqueue {
+ check_data_dir();
+ wait_for_db();
+ exit run_cereal_and_jobqueue()->get;
+}
+
sub cmd_dev_httpd {
my $have_params = -f "/app/data/params";
assert_database->get();