|
Lines 143-150
my ($biblioitemnumbertagfield,$biblioitemnumbertagsubfield) = &GetMarcFromKohaFi
Link Here
|
| 143 |
# We need to create our own lock directory which incorporates the database instance |
143 |
# We need to create our own lock directory which incorporates the database instance |
| 144 |
# we are indexing to facilitate multiple instances on the same machine. |
144 |
# we are indexing to facilitate multiple instances on the same machine. |
| 145 |
|
145 |
|
| 146 |
my $lockdir = C4::Context->config("lockdir"); |
146 |
my $lockdir = C4::Context->config("lockdir") // "/var/lock"; |
| 147 |
$lockdir = "/var/lock" if $lockdir == ""; |
|
|
| 148 |
$lockdir .= ("/koha_rebuild_zebra_" . C4::Context->config("database")); |
147 |
$lockdir .= ("/koha_rebuild_zebra_" . C4::Context->config("database")); |
| 149 |
mkpath($lockdir, 0, oct(755)) unless (-d $lockdir); |
148 |
mkpath($lockdir, 0, oct(755)) unless (-d $lockdir); |
| 150 |
my $lockfile = $lockdir . "/lock"; |
149 |
my $lockfile = $lockdir . "/lock"; |
|
Lines 177-193
open my $LockFH, q{>}, $lockfile or die "$lockfile: $!";
Link Here
|
| 177 |
if ($daemon_mode) { |
176 |
if ($daemon_mode) { |
| 178 |
while (1) { |
177 |
while (1) { |
| 179 |
# For incremental updates, skip the update if the updates are locked |
178 |
# For incremental updates, skip the update if the updates are locked |
| 180 |
if (flock(LockFH, LOCK_EX|LOCK_NB)) { |
179 |
if (flock($LockFH, LOCK_EX|LOCK_NB)) { |
| 181 |
do_one_pass() if ( zebraqueue_not_empty() ); |
180 |
do_one_pass() if ( zebraqueue_not_empty() ); |
| 182 |
flock(LockFH, LOCK_UN); |
181 |
flock($LockFH, LOCK_UN); |
| 183 |
} |
182 |
} |
| 184 |
sleep $daemon_sleep; |
183 |
sleep $daemon_sleep; |
| 185 |
} |
184 |
} |
| 186 |
} else { |
185 |
} else { |
| 187 |
# all one-off invocations, wait for the lock to free |
186 |
# all one-off invocations, wait for the lock to free |
| 188 |
flock(LockFH, LOCK_EX); |
187 |
flock($LockFH, LOCK_EX); |
| 189 |
do_one_pass(); |
188 |
do_one_pass(); |
| 190 |
flock(LockFH, LOCK_UN); |
189 |
flock($LockFH, LOCK_UN); |
| 191 |
} |
190 |
} |
| 192 |
|
191 |
|
| 193 |
|
192 |
|
| 194 |
- |
|
|