Amazon-SQS-Client

 view release on metacpan or  search on metacpan

ChangeLog  view on Meta::CPAN

	* src/main/perl/bin/QueueDaemon.pl.in
	- use Class::Inspector, Class::Unload instead of Module::Loaded
	- add pidfile option
	- pod updates
	(main)
	- don't close Log::Log4perl file handle
	- eval load_handler to catch errors
	- use pidfile if provided
	(init_logger)
	- don't use easy mode
	- support stderr, stdout using Screen appender
	(load_config)
	- option override config file
	- make default logfile stderr
	(load_handler): use Class::Inspector, Class::Unload
	* src/main/perl/lib/Amazon/SQS/Client.pm.in
	- pod tweaks
	(new): allow token as 3rd arg
	(_invoke): pass content to _pauseOnRetry
	(_pauseOnRetry)
	- add content to exception
	- die don't croak
	* src/main/perl/lib/Amazon/SQS/Config.pm.in
	- remove stdout, stderr
	- pod tweaks
	- log_file, log_level
	- add handler_pidfile
	(create_config_accessors)
	- don't die on redefine, just don't redefine
	* src/main/perl/lib/Amazon/SQS/Exception.pm.in
	(new): add _httpError
	(getHTTPError): new

Tue Nov 12 07:42:48 2024  Rob Lauer  <rlauer6@comcast.net>

bin/QueueDaemon.pl  view on Meta::CPAN

log4perl.appender.LOGFILE=Log::Log4perl::Appender::File
log4perl.appender.LOGFILE.filename=%s
log4perl.appender.LOGFILE.mode=append
log4perl.appender.LOGFILE.layout=PatternLayout
log4perl.appender.LOGFILE.layout.ConversionPattern=%%d (%%r,%%R) (%%p/%%c) [%%P] [%%M:%%L] - %%m%%n
END_OF_LOGGER

Readonly::Scalar our $SCREEN_CONFIG => <<'END_OF_LOGGER';
log4perl.rootLogger=INFO, SCREEN
log4perl.appender.SCREEN=Log::Log4perl::Appender::Screen
log4perl.appender.SCREEN.stderr=%s
log4perl.appender.SCREEN.layout=PatternLayout
log4perl.appender.SCREEN.layout.ConversionPattern=%%d (%%r,%%R) (%%p/%%c) [%%P] [%%M:%%L] - %%m%%n
END_OF_LOGGER

our $KEEP_GOING = $TRUE;
our $RELOAD     = $FALSE;

########################################################################
sub get_options {
########################################################################

bin/QueueDaemon.pl  view on Meta::CPAN

  }

  # set up signal handlers
  setup_signal_handlers( \%options, \$handler );

  my $service = $handler->get_service;

  if ( $options{daemonize} ) {
    my @dont_close_fh;

    if ( $options{logfile} && $options{logfile} !~ /(?:stderr|stdout)/ixsm ) {
      my $appender = Log::Log4perl->appender_by_name($APPENDER_NAME);
      push @dont_close_fh, $appender->{fh};
    }

    push @dont_close_fh, 'STDERR';
    push @dont_close_fh, 'STDOUT';

    my %daemon_config = (
      work_dir => cwd,
      @dont_close_fh ? ( dont_close_fh => \@dont_close_fh ) : (),

bin/QueueDaemon.pl  view on Meta::CPAN

  $loglevel = {
    error => $ERROR,
    debug => $DEBUG,
    trace => $TRACE,
    info  => $INFO,
    warn  => $WARN,
  }->{ lc $loglevel };

  $loglevel //= $INFO;

  $logfile //= 'stderr';

  my $log4perl_config;

  if ( !$logfile || $logfile =~ /(?:stderr|stdout)/xsmi ) {
    $log4perl_config    = sprintf $SCREEN_CONFIG, $logfile eq 'stdout' ? 0 : 1;
    $options->{logfile} = lc $logfile;
  }
  else {
    $log4perl_config = sprintf $log4perl_config, $logfile;
  }

  if ( Log::Log4perl->initialized() ) {
    my $logger = Log::Log4perl->get_logger;
    $logger->level($loglevel);

bin/QueueDaemon.pl  view on Meta::CPAN

  my ($options) = @_;

  return
    if !$options->{config};

  my $config = Amazon::SQS::Config->new( file => $options->{config} );

  $options->{loglevel} //= $config->get_log_level;

  $options->{logfile} //= $config->get_log_file;
  $options->{logfile} //= 'stderr';

  $options->{'delete-when'} //= $config->get_error_delete;

  $options->{'exit-when'} //= $config->get_error_exit;

  $options->{handler} //= $config->get_handler_class;

  $options->{'max-sleep-time'} //= $config->get_queue_max_wait;

  $options->{'max-messages'} //= $config->get_queue_max_messages // 1;

lib/Amazon/SQS/Config.pm  view on Meta::CPAN


The log section describe how the F<QueueDaemon.pl> script will log
messages. The script instantiates a L<Log::Log4perl> logger
automatically for you that will log to the parent's STDERR. See note
below regarding how the daemonization process closes STDOUT, STDERR.

  [log]
  level = debug
  file = /tmp/amazon_sqs.log

When you daemonize the script, if either C<stdout> or C<stderr> is set
the parent's STDOUT or STDERR will be closed and then reopened using
those settings. If these are not set, then they will not be
closed. The closing STDERR will stop the C<Log::Log4perl> logger.

=over 5

=item level

C<Log::Log4perl> logging level ('trace', 'debug', 'info', 'warn', 'error').

=item file

Name of a log file for C<Log::Log4perl> messages. You can also use the
values of 'stdout' or 'stderr' to log to STDOUT and STDERR.

=back

I<WARNING: You should probably make sure that the F<.ini> file is properly
protected with restrictive permissions if you place credentials in
this file.>

=head1 METHODS AND SUBROUTINES

=head2 new

t/01-config.t  view on Meta::CPAN

max_wait = 20 
visibility_timeout = 60

[aws]
access_key_id = <Your Access Key ID>
secret_access_key = <Your Secret Access Key>
queue_url = https://queue.amazonaws.com/<your-account-number>/<your-queue-name>

[log]
stdout = /tmp/amazon_sqs.log
stderr = /tmp/amazon_sqs.log



( run in 0.508 second using v1.01-cache-2.11-cpan-49f99fa48dc )