mirror of
https://github.com/webrecorder/browsertrix-crawler.git
synced 2025-10-19 06:23:16 +00:00
add missing lock.js
update chrome launch flag
This commit is contained in:
parent
c0508d44a7
commit
d723f95cb9
2 changed files with 38 additions and 1 deletions
|
@ -259,7 +259,7 @@ class Crawler {
|
|||
"--no-sandbox",
|
||||
"--disable-background-media-suspend",
|
||||
"--autoplay-policy=no-user-gesture-required",
|
||||
"--disable-features=IsolateOrigins,site-per-process",
|
||||
"--disable-features=Translate,LazyFrameLoading,IsolateOrigins,site-per-process",
|
||||
"--disable-popup-blocking",
|
||||
"--disable-backgrounding-occluded-windows",
|
||||
];
|
||||
|
|
37
util/lock.js
Normal file
37
util/lock.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const os = require("os");
|
||||
|
||||
class Lock
|
||||
{
|
||||
constructor(dir) {
|
||||
this.lockDir = path.join(dir, ".lock");
|
||||
this.lockFile = path.join(this.lockDir, "." + os.hostname());
|
||||
fs.mkdirSync(this.lockDir, {recursive: true});
|
||||
fs.closeSync(fs.openSync(this.lockFile, "a"));
|
||||
console.log(`Created lock file ${this.lockFile}`);
|
||||
}
|
||||
|
||||
release() {
|
||||
try {
|
||||
fs.unlinkSync(this.lockFile);
|
||||
console.log(`Removed lock file ${this.lockFile}`);
|
||||
} catch (e) {
|
||||
// ignore remove failure, but see if other locks exist
|
||||
}
|
||||
|
||||
try {
|
||||
fs.rmdirSync(this.lockDir);
|
||||
} catch (e) {
|
||||
// true if no such dir, otherwise not released
|
||||
return (e.code === "ENOENT");
|
||||
}
|
||||
|
||||
console.log("No more locks");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
module.exports.Lock = Lock;
|
Loading…
Add table
Add a link
Reference in a new issue