line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hubot::Scripts::backup; |
2
|
|
|
|
|
|
|
$Hubot::Scripts::backup::VERSION = '0.1.9'; |
3
|
1
|
|
|
1
|
|
1270
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
36
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
5
|
1
|
|
|
1
|
|
1796
|
use AnyEvent; |
|
1
|
|
|
|
|
11006
|
|
|
1
|
|
|
|
|
190
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
my $w; # consider *WATCHER* lifetime |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub load { |
10
|
0
|
|
|
0
|
0
|
|
my ( $class, $robot ) = @_; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$w = AnyEvent->timer( |
13
|
|
|
|
|
|
|
after => 0, |
14
|
|
|
|
|
|
|
interval => $ENV{HUBOT_BACKUP_INTERVAL} || 60 * 60, |
15
|
0
|
|
|
0
|
|
|
cb => sub { $robot->brain->save } |
16
|
0
|
|
0
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$robot->respond( |
19
|
|
|
|
|
|
|
qr/backup$/i, |
20
|
|
|
|
|
|
|
sub { |
21
|
0
|
|
|
0
|
|
|
$robot->brain->save; |
22
|
0
|
|
|
|
|
|
shift->send("OK, saved the robot's brain"); |
23
|
|
|
|
|
|
|
} |
24
|
0
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 NAME |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Hubot::Scripts::backup |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 VERSION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
version 0.1.9 |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SYNOPSIS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
hubot backup - save robot's brain data to external storage immediately if used |
40
|
|
|
|
|
|
|
backup (this is *NOT COMMAND*) - save robot's brain data to external storage automatically if used; just work |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 CONFIGURATION |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=over |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item * HUBOT_BACKUP_INTERVAL |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
C<3600>(1 hour) is default to use. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=back |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 SEE ALSO |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=over |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item * L<Hubot::Scripts::redisBrain> |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=back |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 AUTHOR |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Hyungsuk Hong <hshong@perl.kr> |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |