Revision e36a3c06
Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt
scripts/task_server.pl | ||
---|---|---|
40 | 40 |
|
41 | 41 |
our %lx_office_conf; |
42 | 42 |
|
43 |
sub debug { |
|
44 |
return if !$lx_office_conf{task_server}->{debug}; |
|
45 |
$::lxdebug->message(0, @_); |
|
46 |
} |
|
47 |
|
|
43 | 48 |
sub lxinit { |
44 | 49 |
my $login = $lx_office_conf{task_server}->{login}; |
45 | 50 |
my $client = $lx_office_conf{task_server}->{client}; |
... | ... | |
110 | 115 |
sub gd_run { |
111 | 116 |
while (1) { |
112 | 117 |
my $ok = eval { |
113 |
$::lxdebug->message(0, "Retrieving jobs") if $lx_office_conf{task_server}->{debug};
|
|
118 |
debug("Retrieving jobs");
|
|
114 | 119 |
|
115 | 120 |
my $jobs = SL::DB::Manager::BackgroundJob->get_all_need_to_run; |
116 | 121 |
|
117 |
$::lxdebug->message(0, " Found: " . join(' ', map { $_->package_name } @{ $jobs })) if $lx_office_conf{task_server}->{debug} && @{ $jobs };
|
|
122 |
debug(" Found: " . join(' ', map { $_->package_name } @{ $jobs })) if @{ $jobs };
|
|
118 | 123 |
|
119 | 124 |
foreach my $job (@{ $jobs }) { |
120 | 125 |
# Provide fresh global variables in case legacy code modifies |
... | ... | |
130 | 135 |
1; |
131 | 136 |
}; |
132 | 137 |
|
133 |
if ($lx_office_conf{task_server}->{debug}) { |
|
134 |
$::lxdebug->message(0, "Exception during execution: ${EVAL_ERROR}") if !$ok; |
|
135 |
$::lxdebug->message(0, "Sleeping"); |
|
136 |
} |
|
138 |
debug("Exception during execution: ${EVAL_ERROR}") if !$ok; |
|
139 |
debug("Sleeping"); |
|
137 | 140 |
|
138 | 141 |
my $seconds = 60 - (localtime)[0]; |
139 | 142 |
if (!eval { |
140 | 143 |
local $SIG{'ALRM'} = sub { |
141 |
$::lxdebug->message(0, "Got woken up by SIGALRM") if $lx_office_conf{task_server}->{debug};
|
|
144 |
debug("Got woken up by SIGALRM");
|
|
142 | 145 |
die "Alarm!\n" |
143 | 146 |
}; |
144 | 147 |
sleep($seconds < 30 ? $seconds + 60 : $seconds); |
Auch abrufbar als: Unified diff
Refactoring: Debug-Ausgaben im Task-Server