line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Convos::Control::Backend; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Convos::Control::Backend - Extends Daemon::Control to control Convos backend |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
L is a sub class of L used to |
10
|
|
|
|
|
|
|
control the backend |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Convos::Control::Backend; |
15
|
|
|
|
|
|
|
exit Convos::Control::Backend->new->run; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
5
|
use Mojo::Base 'Convos::Control'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$ENV{CONVOS_BACKEND_PID_FILE} ||= File::Spec->catfile(File::Spec->tmpdir, 'convos-backend.pid'); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 group |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Default to C environment variable or the first group of |
28
|
|
|
|
|
|
|
L. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 lsb_desc |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
"Start Convos backend". |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 lsb_sdesc |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
"Convos backend". |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 name |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
"Convos backend". |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 program |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Returns a callback which can be used to start the backend. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 pid_file |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Default to C environment variable. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 stderr_file |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Default to C environment variable. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 stdout_file |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Default to C environment variable. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 user |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Default to C environment variable or the current user. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
has lsb_desc => 'Start Convos backend'; |
65
|
|
|
|
|
|
|
has lsb_sdesc => 'Convos backend'; |
66
|
|
|
|
|
|
|
has name => 'Convos backend'; |
67
|
|
|
|
|
|
|
has program => sub { \&_start_backend }; |
68
|
|
|
|
|
|
|
has pid_file => sub { $ENV{CONVOS_BACKEND_PID_FILE} }; |
69
|
|
|
|
|
|
|
has stderr_file => sub { $ENV{CONVOS_BACKEND_LOGFILE} || File::Spec->devnull }; |
70
|
|
|
|
|
|
|
has stdout_file => sub { $ENV{CONVOS_BACKEND_LOGFILE} || File::Spec->devnull }; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 METHODS |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 new |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Object constructor. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# This is required, since Daemon::Control::new() sets the defaults |
81
|
|
|
|
|
|
|
sub new { |
82
|
1
|
|
|
1
|
1
|
6
|
my $self = shift->SUPER::new(@_); |
83
|
1
|
|
|
|
|
52
|
$self->reload_signal('USR2'); |
84
|
1
|
50
|
|
|
|
8
|
$self->group($ENV{RUN_AS_GROUP}) unless defined $self->group; |
85
|
1
|
50
|
|
|
|
13
|
$self->user($ENV{RUN_AS_USER}) unless defined $self->user; |
86
|
1
|
|
|
|
|
10
|
$self; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub _start_backend { |
90
|
0
|
|
|
0
|
|
|
local $ENV{CONVOS_BACKEND_ONLY} = 1; |
91
|
0
|
|
|
|
|
|
require Convos; |
92
|
0
|
|
|
|
|
|
my $convos = Convos->new; |
93
|
0
|
|
|
|
|
|
$convos->log->info('Starting convos backend.'); |
94
|
0
|
|
|
|
|
|
$convos->core->start; |
95
|
0
|
|
|
|
|
|
Mojo::IOLoop->start; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Copyright (C) 2014, Jan Henning Thorsen |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
103
|
|
|
|
|
|
|
the terms of the Artistic License version 2.0. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 AUTHOR |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Jan Henning Thorsen - C |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |