line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hubot::Scripts::backup; |
2
|
|
|
|
|
|
|
$Hubot::Scripts::backup::VERSION = '0.1.10'; |
3
|
1
|
|
|
1
|
|
766
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
17
|
|
5
|
1
|
|
|
1
|
|
269
|
use AnyEvent; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
my $w; # consider *WATCHER* lifetime |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub load { |
10
|
|
|
|
|
|
|
my ( $class, $robot ) = @_; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$w = AnyEvent->timer( |
13
|
|
|
|
|
|
|
after => 0, |
14
|
|
|
|
|
|
|
interval => $ENV{HUBOT_BACKUP_INTERVAL} || 60 * 60, |
15
|
|
|
|
|
|
|
cb => sub { $robot->brain->save } |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$robot->respond( |
19
|
|
|
|
|
|
|
qr/backup$/i, |
20
|
|
|
|
|
|
|
sub { |
21
|
|
|
|
|
|
|
$robot->brain->save; |
22
|
|
|
|
|
|
|
shift->send("OK, saved the robot's brain"); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 NAME |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Hubot::Scripts::backup |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 VERSION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
version 0.1.10 |
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 |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=back |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 AUTHOR |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Hyungsuk Hong |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |