Skip to content

Commit

Permalink
[backend] bs_worker: make sure that we don't run old code
Browse files Browse the repository at this point in the history
This could happen when the worker was started from some other
directory than the statedir and the statedir had an up-to-date
copy of the worker code.
  • Loading branch information
mlschroe committed Jun 4, 2018
1 parent f5e1987 commit 9ac97cf
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/backend/bs_worker
Original file line number Diff line number Diff line change
Expand Up @@ -3489,6 +3489,8 @@ sub periodic {


# better safe than sorry...
my $startworkercode = '?';
$startworkercode = codemd5('.') if -e './bs_worker';
chdir($statedir) || die("$statedir: $!\n");

BSServer::deamonize(@ARGV) unless $oneshot;
Expand All @@ -3498,6 +3500,7 @@ $| = 1;
# calculate code meta md5
$workercode = codemd5('worker');
$buildcode = codemd5('build');
$workercode = $buildcode = '?' if $startworkercode ne $workercode;

open(RUNLOCK, '>>', "$statedir/lock") || die("$statedir/lock: $!");
flock(RUNLOCK, LOCK_EX | LOCK_NB) || die("worker is already running on $statedir!\n");
Expand Down

0 comments on commit 9ac97cf

Please sign in to comment.