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
|
||||
`
|
||||
|
||||
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
|
||||
|
||||
Go to web page
|
||||
|
@ -128,17 +140,11 @@ Default : null
|
|||
|
||||
Password for admin interface. No min or max character.
|
||||
|
||||
Add cron task
|
||||
#### Chrome path
|
||||
|
||||
Default : empty
|
||||
|
||||
`
|
||||
sudo crontab -u www-data -e
|
||||
`
|
||||
|
||||
|
||||
`
|
||||
php /var/www/soshot/bin/thumbShoter.php
|
||||
`
|
||||
If path of Chrome/Chromium is not in PATH, you can define here.
|
||||
|
||||
## Usage
|
||||
|
||||
|
|
|
@ -190,6 +190,10 @@ class Backend {
|
|||
$uConfig['key'] = $post->key;
|
||||
}
|
||||
|
||||
if (!empty($post->chromePath)) {
|
||||
$uConfig['chromePath'] = $post->chromePath;
|
||||
}
|
||||
|
||||
$uConfig->toFile($userConfig);
|
||||
|
||||
$newConfig = new Config($userConfig);
|
||||
|
|
|
@ -27,12 +27,15 @@ class MakeThumb {
|
|||
private $open = false;
|
||||
private $conf;
|
||||
private $db;
|
||||
private $chromePath = '';
|
||||
|
||||
function __construct() {
|
||||
|
||||
$this->conf = (object)Config::load([__DIR__ . '/../../datas/config.default.json', '?' . __DIR__ . '/../../datas/config.json'])->all();
|
||||
$this->maxGenPerBatch = $this->conf->maxGenPerBatch;
|
||||
|
||||
$this->chromePath = $this->conf->chromePath;
|
||||
|
||||
foreach (array_slice(glob($this->queuePath . "*.json"), 0, $this->maxGenPerBatch) as $filename) {
|
||||
$this->fileList[] = $filename;
|
||||
}
|
||||
|
@ -102,12 +105,17 @@ class MakeThumb {
|
|||
$browser = $this->openBrowser();
|
||||
}
|
||||
} else {
|
||||
$factory = new BrowserFactory('chromium');
|
||||
$factory = new BrowserFactory($this->chromePath);
|
||||
$browser = $factory->createBrowser([
|
||||
'userAgent' => 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)',
|
||||
'keepAlive' => true,
|
||||
'headless' => true,
|
||||
'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,
|
||||
//'debugLogger' => 'php://stdout',
|
||||
]);
|
||||
|
@ -171,7 +179,7 @@ class MakeThumb {
|
|||
}
|
||||
|
||||
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)
|
||||
$browser = $factory->createBrowser([
|
||||
|
@ -179,6 +187,11 @@ class MakeThumb {
|
|||
'keepAlive' => true,
|
||||
'headless' => true,
|
||||
'windowSize' => [1920, 1080],
|
||||
'customFlags' => [
|
||||
'--disable-dev-shm-usage',
|
||||
'--disable-gpu'
|
||||
],
|
||||
'noSandbox' => true,
|
||||
]);
|
||||
\file_put_contents($this->fileSocket, $browser->getSocketUri(), LOCK_EX);
|
||||
return $browser;
|
||||
|
|
|
@ -7,5 +7,6 @@
|
|||
"permitType": [],
|
||||
"expireCache": 12,
|
||||
"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; ?>>
|
||||
</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>
|
||||
<input type="hidden" name="page" value="settings">
|
||||
<input type="hidden" name="token" value="<?= $token;?>">
|
||||
|
|
Loading…
Reference in a new issue