This commit is contained in:
garnier-quentin 2020-06-15 09:20:24 +02:00
parent dc37cbd410
commit f6cc6f07f0

View File

@ -44,6 +44,7 @@ sub new {
'statefile-suffix:s' => { name => 'statefile_suffix', default => '' }, 'statefile-suffix:s' => { name => 'statefile_suffix', default => '' },
'statefile-concat-cwd' => { name => 'statefile_concat_cwd' }, 'statefile-concat-cwd' => { name => 'statefile_concat_cwd' },
'statefile-storable' => { name => 'statefile_storable' }, 'statefile-storable' => { name => 'statefile_storable' },
'failback-file' => { name => 'failback_file' }
}); });
$options{options}->add_help(package => __PACKAGE__, sections => 'RETENTION OPTIONS', once => 1); $options{options}->add_help(package => __PACKAGE__, sections => 'RETENTION OPTIONS', once => 1);
} }
@ -89,6 +90,7 @@ sub check_options {
error_msg => "Cannot load module 'Redis'." error_msg => "Cannot load module 'Redis'."
); );
eval { eval {
$options{option_results}->{redis_server} .= ':6379' if ($options{option_results}->{redis_server} !~ /:\d+$/);
$self->{redis_cnx} = Redis->new( $self->{redis_cnx} = Redis->new(
server => $options{option_results}->{redis_server}, server => $options{option_results}->{redis_server},
eval $self->{redis_attributes} eval $self->{redis_attributes}
@ -100,6 +102,10 @@ sub check_options {
$self->{redis_cnx}->select($options{option_results}->{redis_db}); $self->{redis_cnx}->select($options{option_results}->{redis_db});
} }
}; };
if (!defined($self->{redis_cnx}) && !defined($options{option_results}->{failback_file})) {
$self->{output}->add_option_msg(short_msg => "redis connection issue: $@");
$self->{output}->option_exit();
}
} }
$self->{statefile_dir} = $options{option_results}->{statefile_dir}; $self->{statefile_dir} = $options{option_results}->{statefile_dir};
@ -285,7 +291,7 @@ Memcached server to use (only one server).
=item B<--redis-server> =item B<--redis-server>
Redis server to use (only one server). Redis server to use (only one server). SYntax: address[:port]
=item B<--redis-attribute> =item B<--redis-attribute>
@ -295,6 +301,10 @@ Set Redis Options (--redis-attribute="cnx_timeout=5").
Set Redis database index. Set Redis database index.
=item B<--failback-file>
Failback on a local file if redis connection failed.
=item B<--memexpiration> =item B<--memexpiration>
Time to keep data in seconds (Default: 86400). Time to keep data in seconds (Default: 86400).