Commit 328cf5e1 authored by Gaël Berthaud-Müller's avatar Gaël Berthaud-Müller
Browse files

add redis configuration section

parent 8be1a7fc
......@@ -127,7 +127,7 @@ sub parse {
# Validate section names
{
my %sections = map { $_ => 1 } ( 'DB', 'MYSQL', 'POSTGRESQL', 'SQLITE', 'LANGUAGE', 'PUBLIC PROFILES', 'PRIVATE PROFILES', 'ZONEMASTER', 'METRICS', 'RPCAPI' );
my %sections = map { $_ => 1 } ( 'DB', 'MYSQL', 'POSTGRESQL', 'SQLITE', 'LANGUAGE', 'PUBLIC PROFILES', 'PRIVATE PROFILES', 'ZONEMASTER', 'METRICS', 'RPCAPI', 'REDIS' );
for my $section ( $ini->Sections ) {
if ( !exists $sections{$section} ) {
die "config: unrecognized section: $section\n";
......@@ -286,6 +286,12 @@ sub parse {
if ( defined( my $value = $get_and_clear->( 'RPCAPI', 'enable_add_batch_job' ) ) ) {
$obj->_set_RPCAPI_enable_add_batch_job( $value );
}
if ( defined( my $value = $get_and_clear->( 'REDIS', 'host' ) ) ) {
$obj->_set_REDIS_host( $value );
}
if ( defined( my $value = $get_and_clear->( 'REDIS', 'port' ) ) ) {
$obj->_set_REDIS_port( $value );
}
if ( defined( my $value = $get_and_clear->( 'LANGUAGE', 'locale' ) ) ) {
if ( $value ne "" ) {
$obj->_reset_LANGUAGE_locale();
......@@ -631,6 +637,8 @@ sub METRICS_statsd_host { return $_[0]->{_METRIC
sub METRICS_statsd_port { return $_[0]->{_METRICS_statsd_port}; }
sub RPCAPI_enable_add_api_user { return $_[0]->{_RPCAPI_enable_add_api_user}; }
sub RPCAPI_enable_add_batch_job { return $_[0]->{_RPCAPI_enable_add_batch_job}; }
sub REDIS_host { return $_[0]->{_REDIS_host}; }
sub REDIS_port { return $_[0]->{_REDIS_port}; }
# Compile time generation of setters for the properties documented above
UNITCHECK {
......@@ -655,6 +663,8 @@ UNITCHECK {
_create_setter( '_set_METRICS_statsd_port', '_METRICS_statsd_port', \&untaint_strictly_positive_int );
_create_setter( '_set_RPCAPI_enable_add_api_user', '_RPCAPI_enable_add_api_user', \&untaint_bool );
_create_setter( '_set_RPCAPI_enable_add_batch_job', '_RPCAPI_enable_add_batch_job', \&untaint_bool );
_create_setter( '_set_REDIS_host', '_REDIS_host', \&untaint_host );
_create_setter( '_set_REDIS_port', '_REDIS_port', \&untaint_strictly_positive_int );
}
=head2 new_DB
......
......@@ -20,6 +20,7 @@ use Getopt::Long;
use POSIX;
use Time::HiRes qw[time sleep gettimeofday tv_interval];
use sigtrap qw(die normal-signals);
use Redis;
###
### Compile-time stuff.
......@@ -135,7 +136,12 @@ sub main {
local $SIG{TERM} = $catch_sigterm;
local $SIG{INT} = $catch_sigterm;
my $queue = Zonemaster::Backend::RedisQueue->new( dbh => $self->db->dbh );
my $queue = Zonemaster::Backend::RedisQueue->new(
dbh => $self->db->dbh,
redis => Redis->new(
server => $self->config->REDIS_host . ":" . $self->config->REDIS_port
)
);
my $agent = Zonemaster::Backend::TestAgent->new( { config => $self->config } );
# Disconnect from database in parent to avoid sharing the connection between children
$agent->{_db}->dbh->disconnect;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment