autoupdater: add lockfile to prevent concurrent runs

This commit is contained in:
Matthias Schiffer 2016-09-08 02:29:46 +02:00
parent 515a9f48fb
commit 1acb4b1d3a
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
1 changed files with 12 additions and 0 deletions

View File

@ -309,6 +309,18 @@ local function autoupdate(mirror)
end
local lockfile = '/var/lock/autoupdater.lock'
local lockfd = nixio.open(lockfile, 'w', 'rw-------')
if not lockfd:lock('tlock') then
io.stderr:write(string.format(
"Unable to lock file %s. Make sure there is no other instance of the autoupdater running.\n",
lockfile, err
))
os.exit(1)
end
local mirrors = branch.mirror
while #mirrors > 0 do