Add option for define Chrome path
Fix problem whis Soshot and Docker
This commit is contained in:
parent
a7bb641774
commit
ba60aace6b
5 changed files with 41 additions and 12 deletions
24
README.md
24
README.md
|
@ -55,6 +55,18 @@ Install dependencies
|
||||||
composer install --no-dev
|
composer install --no-dev
|
||||||
`
|
`
|
||||||
|
|
||||||
|
Add cron task
|
||||||
|
|
||||||
|
|
||||||
|
`
|
||||||
|
sudo crontab -u www-data -e
|
||||||
|
`
|
||||||
|
|
||||||
|
|
||||||
|
`
|
||||||
|
php /var/www/soshot/bin/thumbShoter.php
|
||||||
|
`
|
||||||
|
|
||||||
Configure your web server to serve in "public" directory
|
Configure your web server to serve in "public" directory
|
||||||
|
|
||||||
Go to web page
|
Go to web page
|
||||||
|
@ -128,17 +140,11 @@ Default : null
|
||||||
|
|
||||||
Password for admin interface. No min or max character.
|
Password for admin interface. No min or max character.
|
||||||
|
|
||||||
Add cron task
|
#### Chrome path
|
||||||
|
|
||||||
|
Default : empty
|
||||||
|
|
||||||
`
|
If path of Chrome/Chromium is not in PATH, you can define here.
|
||||||
sudo crontab -u www-data -e
|
|
||||||
`
|
|
||||||
|
|
||||||
|
|
||||||
`
|
|
||||||
php /var/www/soshot/bin/thumbShoter.php
|
|
||||||
`
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
|
|
@ -190,6 +190,10 @@ class Backend {
|
||||||
$uConfig['key'] = $post->key;
|
$uConfig['key'] = $post->key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($post->chromePath)) {
|
||||||
|
$uConfig['chromePath'] = $post->chromePath;
|
||||||
|
}
|
||||||
|
|
||||||
$uConfig->toFile($userConfig);
|
$uConfig->toFile($userConfig);
|
||||||
|
|
||||||
$newConfig = new Config($userConfig);
|
$newConfig = new Config($userConfig);
|
||||||
|
|
|
@ -27,12 +27,15 @@ class MakeThumb {
|
||||||
private $open = false;
|
private $open = false;
|
||||||
private $conf;
|
private $conf;
|
||||||
private $db;
|
private $db;
|
||||||
|
private $chromePath = '';
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
|
|
||||||
$this->conf = (object)Config::load([__DIR__ . '/../../datas/config.default.json', '?' . __DIR__ . '/../../datas/config.json'])->all();
|
$this->conf = (object)Config::load([__DIR__ . '/../../datas/config.default.json', '?' . __DIR__ . '/../../datas/config.json'])->all();
|
||||||
$this->maxGenPerBatch = $this->conf->maxGenPerBatch;
|
$this->maxGenPerBatch = $this->conf->maxGenPerBatch;
|
||||||
|
|
||||||
|
$this->chromePath = $this->conf->chromePath;
|
||||||
|
|
||||||
foreach (array_slice(glob($this->queuePath . "*.json"), 0, $this->maxGenPerBatch) as $filename) {
|
foreach (array_slice(glob($this->queuePath . "*.json"), 0, $this->maxGenPerBatch) as $filename) {
|
||||||
$this->fileList[] = $filename;
|
$this->fileList[] = $filename;
|
||||||
}
|
}
|
||||||
|
@ -102,12 +105,17 @@ class MakeThumb {
|
||||||
$browser = $this->openBrowser();
|
$browser = $this->openBrowser();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$factory = new BrowserFactory('chromium');
|
$factory = new BrowserFactory($this->chromePath);
|
||||||
$browser = $factory->createBrowser([
|
$browser = $factory->createBrowser([
|
||||||
'userAgent' => 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)',
|
'userAgent' => 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)',
|
||||||
'keepAlive' => true,
|
'keepAlive' => true,
|
||||||
'headless' => true,
|
'headless' => true,
|
||||||
'windowSize' => [1920, 1080],
|
'windowSize' => [1920, 1080],
|
||||||
|
'customFlags' => [
|
||||||
|
'--disable-dev-shm-usage',
|
||||||
|
'--disable-gpu'
|
||||||
|
],
|
||||||
|
'noSandbox' => true,
|
||||||
//'connectionDelay' => 0.8, // add 0.8 second of delay between each instruction sent to chrome,
|
//'connectionDelay' => 0.8, // add 0.8 second of delay between each instruction sent to chrome,
|
||||||
//'debugLogger' => 'php://stdout',
|
//'debugLogger' => 'php://stdout',
|
||||||
]);
|
]);
|
||||||
|
@ -171,7 +179,7 @@ class MakeThumb {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function openBrowser() {
|
private function openBrowser() {
|
||||||
$factory = new BrowserFactory('chromium');
|
$factory = new BrowserFactory($this->chromePath);
|
||||||
|
|
||||||
// Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
|
// Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
|
||||||
$browser = $factory->createBrowser([
|
$browser = $factory->createBrowser([
|
||||||
|
@ -179,6 +187,11 @@ class MakeThumb {
|
||||||
'keepAlive' => true,
|
'keepAlive' => true,
|
||||||
'headless' => true,
|
'headless' => true,
|
||||||
'windowSize' => [1920, 1080],
|
'windowSize' => [1920, 1080],
|
||||||
|
'customFlags' => [
|
||||||
|
'--disable-dev-shm-usage',
|
||||||
|
'--disable-gpu'
|
||||||
|
],
|
||||||
|
'noSandbox' => true,
|
||||||
]);
|
]);
|
||||||
\file_put_contents($this->fileSocket, $browser->getSocketUri(), LOCK_EX);
|
\file_put_contents($this->fileSocket, $browser->getSocketUri(), LOCK_EX);
|
||||||
return $browser;
|
return $browser;
|
||||||
|
|
|
@ -7,5 +7,6 @@
|
||||||
"permitType": [],
|
"permitType": [],
|
||||||
"expireCache": 12,
|
"expireCache": 12,
|
||||||
"maxGenPerBatch": 5,
|
"maxGenPerBatch": 5,
|
||||||
"icoSize": 48
|
"icoSize": 48,
|
||||||
|
"chromePath" : ""
|
||||||
}
|
}
|
|
@ -59,6 +59,11 @@ use App\Utils\Page;
|
||||||
<input class="w3-input w3-border" type="password" name="password" value="" <?= $this->passwordRequired; ?>>
|
<input class="w3-input w3-border" type="password" name="password" value="" <?= $this->passwordRequired; ?>>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<label>Chrome path (if empty, SoShot use default value "chrome or chromium")</label>
|
||||||
|
<input class="w3-input w3-border" type="text" name="chromePath" value="<?= $this->conf->chromePath; ?>">
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<input type="hidden" name="page" value="settings">
|
<input type="hidden" name="page" value="settings">
|
||||||
<input type="hidden" name="token" value="<?= $token;?>">
|
<input type="hidden" name="token" value="<?= $token;?>">
|
||||||
|
|
Loading…
Reference in a new issue