« blib/lib/Ereshkigal/App/Command/cidr_ban.pm
↑ Summary
blib/lib/Ereshkigal/App/Command/re_init.pm »
| 1 | package Ereshkigal::App::Command::checkpoint; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use 5.006; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use Ereshkigal::App -command; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | =head1 NAME | ||||||||||
| 9 | |||||||||||
| 10 | Ereshkigal::App::Command::checkpoint - Force kur instances to write their ban state CSV out now. | ||||||||||
| 11 | |||||||||||
| 12 | =head1 VERSION | ||||||||||
| 13 | |||||||||||
| 14 | Version 0.0.1 | ||||||||||
| 15 | |||||||||||
| 16 | =cut | ||||||||||
| 17 | |||||||||||
| 18 | 2 | our $VERSION = '0.0.1'; | |||||||||
| 19 | |||||||||||
| 20 | =head1 SYNOPSIS | ||||||||||
| 21 | |||||||||||
| 22 | # every kur checkpoints | ||||||||||
| 23 | ereshkigal checkpoint | ||||||||||
| 24 | |||||||||||
| 25 | # just sshd | ||||||||||
| 26 | ereshkigal checkpoint sshd | ||||||||||
| 27 | |||||||||||
| 28 | =head1 DESCRIPTION | ||||||||||
| 29 | |||||||||||
| 30 | Forces kurs to write their tablets out now. Each kur persists what it is | ||||||||||
| 31 | holding to CSVs under the cache dir, so timed bans survive a restart with the | ||||||||||
| 32 | right time left on them. | ||||||||||
| 33 | |||||||||||
| 34 | Those writes already happen on every ban and unban, every C<checkpoint> | ||||||||||
| 35 | seconds, and at stop, so this is rarely needed... it is for taking a | ||||||||||
| 36 | consistent snapshot before a backup or a manual look at the files. Writes are | ||||||||||
| 37 | atomic, so a checkpoint racing a backup cannot hand out half a file. | ||||||||||
| 38 | |||||||||||
| 39 | With no args every kur checkpoints; with a kur name only that one, and naming | ||||||||||
| 40 | a fan_out gate reaches every kur behind it. | ||||||||||
| 41 | |||||||||||
| 42 | =head1 METHODS | ||||||||||
| 43 | |||||||||||
| 44 | The App::Cmd hooks this subcommand supplies... abstract, description, | ||||||||||
| 45 | usage_desc, validate_args, and execute. | ||||||||||
| 46 | |||||||||||
| 47 | =cut | ||||||||||
| 48 | |||||||||||
| 49 | 1 | ▶ | sub abstract { return 'force kur instances to write their ban state CSV out now' } | ||||||||
|
Subroutine
abstract: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 50 | |||||||||||
| 51 | 4 | ▶ | sub description { | ||||||||
|
Subroutine
description: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 52 | 4 | return <<'DESCRIPTION'; | |||||||||
| 53 | Force kurs to write their tablets out now. | ||||||||||
| 54 | |||||||||||
| 55 | Each kur persists what it is holding to CSVs under the cache dir, so | ||||||||||
| 56 | timed bans survive a restart with the right time left on them. Those | ||||||||||
| 57 | writes already happen on every ban and unban, every checkpoint seconds, | ||||||||||
| 58 | and at stop, so you rarely need this... it is here for taking a | ||||||||||
| 59 | consistent snapshot before a backup or a manual poke at the files. | ||||||||||
| 60 | |||||||||||
| 61 | With no args every kur checkpoints; with a kur name only that one, and | ||||||||||
| 62 | naming a fan_out gate reaches every kur behind it. | ||||||||||
| 63 | |||||||||||
| 64 | Writes are atomic, so a checkpoint racing a backup cannot hand you half | ||||||||||
| 65 | a file. | ||||||||||
| 66 | DESCRIPTION | ||||||||||
| 67 | } ## end sub description | ||||||||||
| 68 | |||||||||||
| 69 | 8 | ▶ | sub usage_desc { return '%c checkpoint %o [kur]'; } | ||||||||
|
Subroutine
usage_desc: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 70 | |||||||||||
| 71 | 4 | ▶ | sub validate_args { | ||||||||
|
Subroutine
validate_args: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 72 | 4 | my ( $self, $opt, $args ) = @_; | |||||||||
| 73 | |||||||||||
| 74 | 4 | ▶ | if ( @{$args} > 1 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 75 | 1 | $self->usage_error('checkpoint takes at most one arg, a kur instance name'); | |||||||||
| 76 | } | ||||||||||
| 77 | |||||||||||
| 78 | 3 | return; | |||||||||
| 79 | } | ||||||||||
| 80 | |||||||||||
| 81 | 3 | ▶ | sub execute { | ||||||||
|
Subroutine
execute: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 82 | 3 | my ( $self, $opt, $args ) = @_; | |||||||||
| 83 | |||||||||||
| 84 | 3 | ▶ | $self->run_command( 'checkpoint', @{$args} ? { 'kur' => $args->[0] } : undef ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 85 | |||||||||||
| 86 | 2 | return; | |||||||||
| 87 | } | ||||||||||
| 88 | |||||||||||
| 89 | 2 | 1; | |||||||||