Revision e08abae0
Von Moritz Bunkus vor fast 14 Jahren hinzugefügt
scripts/task_server.pl | ||
---|---|---|
31 | 31 |
use SL::LXDebug; |
32 | 32 |
use SL::Locale; |
33 | 33 |
|
34 |
my %config;
|
|
34 |
our %lx_office_conf;
|
|
35 | 35 |
|
36 | 36 |
# this is a cleaned up version of am.pl |
37 | 37 |
# it lacks redirection, some html setup and most of the authentication process. |
38 | 38 |
# it is assumed that anyone with physical access and execution rights on this script |
39 | 39 |
# won't be hindered by authentication anyway. |
40 | 40 |
sub lxinit { |
41 |
my $login = $config{task_server}->{login};
|
|
41 |
my $login = $lx_office_conf{task_server}->{login};
|
|
42 | 42 |
|
43 | 43 |
package main; |
44 | 44 |
|
... | ... | |
68 | 68 |
} |
69 | 69 |
|
70 | 70 |
sub drop_privileges { |
71 |
my $user = $::emmvee_conf{task_server}->{run_as};
|
|
71 |
my $user = $lx_office_conf{task_server}->{run_as};
|
|
72 | 72 |
return unless $user; |
73 | 73 |
|
74 | 74 |
my ($uid, $gid); |
... | ... | |
98 | 98 |
sub gd_preconfig { |
99 | 99 |
my $self = shift; |
100 | 100 |
|
101 |
read_config $self->{configfile} => %config;
|
|
101 |
read_config $self->{configfile} => %lx_office_conf;
|
|
102 | 102 |
|
103 |
die "Missing section [task_server] in config file" unless $config{task_server};
|
|
104 |
die "Missing key 'login' in section [task_server] in config file" unless $config{task_server}->{login};
|
|
103 |
die "Missing section [task_server] in config file" unless $lx_office_conf{task_server};
|
|
104 |
die "Missing key 'login' in section [task_server] in config file" unless $lx_office_conf{task_server}->{login};
|
|
105 | 105 |
|
106 | 106 |
drop_privileges(); |
107 | 107 |
lxinit(); |
... | ... | |
112 | 112 |
sub gd_run { |
113 | 113 |
while (1) { |
114 | 114 |
my $ok = eval { |
115 |
$::lxdebug->message(0, "Retrieving jobs") if $config{task_server}->{debug};
|
|
115 |
$::lxdebug->message(0, "Retrieving jobs") if $lx_office_conf{task_server}->{debug};
|
|
116 | 116 |
|
117 | 117 |
my $jobs = SL::DB::Manager::BackgroundJob->get_all_need_to_run; |
118 | 118 |
|
119 |
$::lxdebug->message(0, " Found: " . join(' ', map { $_->package_name } @{ $jobs })) if $config{task_server}->{debug} && @{ $jobs };
|
|
119 |
$::lxdebug->message(0, " Found: " . join(' ', map { $_->package_name } @{ $jobs })) if $lx_office_conf{task_server}->{debug} && @{ $jobs };
|
|
120 | 120 |
|
121 | 121 |
foreach my $job (@{ $jobs }) { |
122 | 122 |
# Provide fresh global variables in case legacy code modifies |
... | ... | |
130 | 130 |
1; |
131 | 131 |
}; |
132 | 132 |
|
133 |
if ($config{task_server}->{debug}) {
|
|
133 |
if ($lx_office_conf{task_server}->{debug}) {
|
|
134 | 134 |
$::lxdebug->message(0, "Exception during execution: ${EVAL_ERROR}") if !$ok; |
135 | 135 |
$::lxdebug->message(0, "Sleeping"); |
136 | 136 |
} |
Auch abrufbar als: Unified diff
Globales Konfigurationsobjekt %lx_office_conf zur Verfügung stellen