]> _ Git - fluidbook_processfarm.git/commitdiff
wip #5506 @9
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 5 Oct 2022 09:50:44 +0000 (11:50 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 5 Oct 2022 09:50:44 +0000 (11:50 +0200)
31 files changed:
.gitignore
.ssh/authorized_keys [deleted file]
.ssh/id_rsa [deleted file]
.ssh/id_rsa.pub [deleted file]
.ssh/known_hosts [deleted file]
Dockerfile [new file with mode: 0644]
README.md
app/bin/mount [new file with mode: 0755]
app/composer.json [new file with mode: 0644]
app/info.php [new file with mode: 0644]
app/ping.php [new file with mode: 0644]
app/process.php [new file with mode: 0644]
app/src/ProcessFile.php [new file with mode: 0644]
bin/fixrights [deleted file]
bin/install [deleted file]
bin/installpackages [deleted file]
bin/mount [deleted file]
bin/ping [deleted file]
bin/process [deleted file]
bin/process.php [deleted file]
bin/update [deleted file]
composer.json [deleted file]
docker-compose.yml [new file with mode: 0644]
etc/sudoers [deleted file]
overrides.conf [new file with mode: 0644]
src/Process.php [deleted file]
ssh/id_rsa [new file with mode: 0644]
ssh/id_rsa.pub [new file with mode: 0644]
ssh/known_hosts [new file with mode: 0644]
startup [new file with mode: 0755]
update [new file with mode: 0755]

index f485327f2327394a99d39194f8c91e6d09a14821..ad2b13e86a681fba3fdab1374626a7203d429893 100644 (file)
@@ -1,5 +1,5 @@
 ### Laravel template
-/vendor/
+/app/vendor/
 node_modules/
 npm-debug.log
 yarn-error.log
diff --git a/.ssh/authorized_keys b/.ssh/authorized_keys
deleted file mode 100644 (file)
index 2330a97..0000000
+++ /dev/null
@@ -1 +0,0 @@
-ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3vHNE7na68aUPFwAK4h3VW+PR4GZaLsTCdySLdt8974jKltMDfWdEbM//mQOm4nOLDkPkbn+TX0GuTNu/SnFTP/qnG7e+p+pqhuYrvw9CHBHtsGoPZS1ZWs53wuXbuJmYTzJMaMV+dibRh2rX/uzH7dBNVQJMGFcQkjrq/UnhJTgKZPprhx2tDV4Rm72GXH4JOi+yautM7jK21gpxdFUJy7VaNaPB1iqcCikn+htCNs1n8BjVRwAMPI9AB6eEgfX68DyVF80TGLyWxlCumFOZXDELhOneJtO0zFMSEuBVXbPm2fNq1jaMaeqgmZqQiZNM0o4hqW/ZLcRH0k+gGXHH extranet@amarcord.cubedesigners.com
\ No newline at end of file
diff --git a/.ssh/id_rsa b/.ssh/id_rsa
deleted file mode 100644 (file)
index 887177c..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
------BEGIN OPENSSH PRIVATE KEY-----
-b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
-NhAAAAAwEAAQAAAYEAt5L4zbBY/Pw9RtsBOqbjXEuFcBRwET5oCjRcYLQ8vmvoB3A4rsoG
-IWYycvJWKaNNjeyNpFfTKN/p1h9QIp9RW4wD1Rj+VQcLo64hSZH3Dnr++m/LsFbP8RcHSZ
-9znNAJ1b7v9N7b2b9b1VZgBhP0umJvQZgg1VgtqTlXckr7doZpY0qEGmUMz0+Qx3cIHp2w
-z1Nuk5knIRUcvyv2t9vo7rmvD/nnHjsqYvm81dCu9t4eMebXquK0JrG6hWpX1J4dBQGHV2
-85E1wX4RP4eA/E5BjJAgoESUrsOSOUj91xLgxAduAc3eRxIwEIK4oBhNi+ve7GBICZIre1
-lDkJgdQ6JIKgnNxoJH1BOv9EynjXl0L9ec+4UPdfdkJ46Nme6nJ3m4ma6M8aOYu7QKybLB
-3pK5DCMxeLo1S9Fiy8V7fOWADfwAeANeQdZUzNQsmq6e5BSt5lQ+54nCWLAmqRIGlWvIpu
-jCCaAEoOP6kQqwNNOi0Kgtk8l+cIvZhAoCYSgqfNAAAFmIj8CVWI/AlVAAAAB3NzaC1yc2
-EAAAGBALeS+M2wWPz8PUbbATqm41xLhXAUcBE+aAo0XGC0PL5r6AdwOK7KBiFmMnLyVimj
-TY3sja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3DyX7
-qkKTHlgQR8LQclWFyyy6+rg+y6NBCoQjYtKd19JYh8+LSHhHBYdFDjmz170obTbuYBRhs6
-z6U884P+oivjwq4LLf7cBEjlK5BdpY9TO8ezEUwTy5gSHJzmHW8KZJuzTWrXzfa6/ZrQ4p
-I+i9XPLKO/U1VqnqCHVPjcQlGoIwvvC0pNC5e9FcRq2vMlxwIAAADBAO/gUnLqD3PvzQaw
-xn54nbJtf+5Vd/H6pbMurI7e+X6YzE5A75k1RtIi2E3vY7T94Q1RAZNLXGGE43ftuc2oQr
-+O5nNE5IBzjJV/UCmcyC1I5Br6pE0pFTE5jREcNO/HL/rTMZZpT3irTwIXAYA9W68PXFU+
-sEffCoxLBS2zZ0St9IrRRe84/Sqh44HQ2isn1t7yTVMdJoMrHppl8NE8uvZAPc51zm0tHi
-cdJyN3inLuHvMPNMqFAGBMRkooTUIcBwAAAMEAw+nUMofwyktlQi41FR5uyPfbfkMJ75f1
-FDSFzVjyzocJRCMaXCB7SOUU1m0FuVHYbCbqSWYqQLCcLGjMKfL20QwY95HwdhDugLhCuM
-ex5y2oeBjy8B/1RSzmmpeRyO6godYrJCl8aQmQeCNQGjBO5mp5VFSAfLl0DaSaLs9pWQM1
-0yFdFK11Pzdk+CJ9icCRcSMvZOBX/F27XvXbYxXy4LUqwCZVQsB51azJNOtNwEXqbxNC9p
-O713DLwIKl+xCLAAAAHXJvb3RAYmF0bWFuLmN1YmVkZXNpZ25lcnMuY29tAQIDBAU=
------END OPENSSH PRIVATE KEY-----
diff --git a/.ssh/id_rsa.pub b/.ssh/id_rsa.pub
deleted file mode 100644 (file)
index f7abdde..0000000
+++ /dev/null
@@ -1 +0,0 @@
-ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC3kvjNsFj8/D1G2wE6puNcS4VwFHARPmgKNFxgtDy+a+gHcDiuygYhZjJy8lYpo02N7I2kV9Mo3+nWH1Ain1FbjAPVGP5VBwujriFJkfcOev76b8uwVs/xFwdJn3Oc0AnVvu/03tvZv1vVVmAGE/S6Ym9BmCDVWC2pOVdySvt2hmljSoQaZQzPT5DHdwgenbDPU26TmSchFRy/K/a32+juua8P+eceOypi+bzV0K723h4x5teq4rQmsbqFalfUnh0FAYdXbzkTXBfhE/h4D8TkGMkCCgRJSuw5I5SP3XEuDEB24Bzd5HEjAQgrigGE2L697sYEgJkit7WUOQmB1DokgqCc3GgkfUE6/0TKeNeXQv15z7hQ9192Qnjo2Z7qcnebiZrozxo5i7tArJssHekrkMIzF4ujVL0WLLxXt85YAN/AB4A15B1lTM1Cyarp7kFK3mVD7nicJYsCapEgaVa8im6MIJoASg4/qRCrA006LQqC2TyX5wi9mECgJhKCp80= fluidbookfarmer@cubedesigners.com
diff --git a/.ssh/known_hosts b/.ssh/known_hosts
deleted file mode 100644 (file)
index 0ec6ea9..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-|1|I3upUS72GkBN0XrvRynC+54Jkjw=|g0RQmSMtyO/SJJur7ff701QpAlk= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBIcf3EkFhhbkL74VV3dG/ZN6X7Do+JDfzw0l7VJX6EmuTM3l2oNdg5jDp4vRHT8c9SKVe/JumeiAkIa/h6fVD4Y=
-|1|Lmv+DVNc45mnhZBQFn+lUcaRRiY=|yOB0mGpn2+50dOkb+stX7Ho5ZwQ= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBIcf3EkFhhbkL74VV3dG/ZN6X7Do+JDfzw0l7VJX6EmuTM3l2oNdg5jDp4vRHT8c9SKVe/JumeiAkIa/h6fVD4Y=
diff --git a/Dockerfile b/Dockerfile
new file mode 100644 (file)
index 0000000..d317418
--- /dev/null
@@ -0,0 +1,19 @@
+FROM ubuntu:jammy
+WORKDIR "/application"
+
+ENV TERM=linux
+ENV DEBIAN_FRONTEND=noninteractive
+
+RUN apt-get update && apt-get install -y --no-install-recommends gnupg \
+    && echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ondrej-php.list \
+    && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C \
+    && apt-get update \
+    && apt-get -y --no-install-recommends install x11-common pdftk poppler-utils ghostscript netpbm sshfs mupdf-tools php8.1-cli php8.1-fpm php8.1-curl php8.1-exif php8.1-xml php8.1-gd php8.1-ssh php8.1-zip libjpeg-turbo-progs zip unzip \
+        less nano wget bash lynx
+
+COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
+COPY overrides.conf /etc/php/8.1/fpm/pool.d/z-overrides.conf
+COPY --chmod=755 startup /usr/bin/startup
+CMD exec /usr/bin/startup
+STOPSIGNAL SIGQUIT
+EXPOSE 9000
index a2873cd4756d95bd5ee00b624991f13f05276c84..68321e8867731fa37c4aa392ef2093b0b78a2178 100644 (file)
--- a/README.md
+++ b/README.md
@@ -2,8 +2,4 @@
 
 On the farming server : 
 
-`apt install -y git;cd /usr/local/;git clone git://git.cubedesigners.com/fluidbook_processfarm.git;/usr/local/fluidbook_processfarm/bin/install`
-
-On the alien server (logged in as extranet), connect once on the new farming server to add it to known host
-
-`ssh -p 22 fluidbookfarmer@host.cubedesigners.com`
\ No newline at end of file
+`apt install -y git;mkdir -p /docker/fluidbook-processfarm;git clone git://git.cubedesigners.com/fluidbook_processfarm.git .;./update`
\ No newline at end of file
diff --git a/app/bin/mount b/app/bin/mount
new file mode 100755 (executable)
index 0000000..a2da5dc
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/bash
+mkdir -p /files
+if mountpoint -q "/files"; then
+    :
+else
+    sshfs -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 -o uid=33 -o gid=33 -o allow_other root@godzilla.cubedesigners.com:/data/fluidbook/docs /files
+fi
\ No newline at end of file
diff --git a/app/composer.json b/app/composer.json
new file mode 100644 (file)
index 0000000..7b1eff3
--- /dev/null
@@ -0,0 +1,28 @@
+{
+  "name": "fluidbook/processfarm",
+  "description": "description",
+  "minimum-stability": "dev",
+  "license": "proprietary",
+  "repositories": [
+    {
+      "type": "composer",
+      "url": "https://composer.cubedesigners.com/"
+    }
+  ],
+  "authors": [
+    {
+      "name": "Vincent VANWAELSCAPPEL",
+      "email": "vincent@cubedesigners.com"
+    }
+  ],
+  "autoload": {
+    "psr-4": {
+      "Fluidbook\\Farmer\\": "src"
+    }
+  },
+  "prefer-stable": true,
+  "require": {
+    "php": ">=8.0",
+    "fluidbook/tools": "dev-master"
+  }
+}
\ No newline at end of file
diff --git a/app/info.php b/app/info.php
new file mode 100644 (file)
index 0000000..bfd863b
--- /dev/null
@@ -0,0 +1,2 @@
+<?php
+phpinfo();
\ No newline at end of file
diff --git a/app/ping.php b/app/ping.php
new file mode 100644 (file)
index 0000000..31ed9e8
--- /dev/null
@@ -0,0 +1,2 @@
+<?php
+die(file_exists('/files/status') ? '1' : '0');
\ No newline at end of file
diff --git a/app/process.php b/app/process.php
new file mode 100644 (file)
index 0000000..7dbde92
--- /dev/null
@@ -0,0 +1,8 @@
+<?php
+
+use Fluidbook\Farmer\ProcessFile;
+
+require_once __DIR__ . "/vendor/autoload.php";
+
+$p = new ProcessFile($_POST['out'], $_POST['page'], $_POST['resolutionRatio'], $_POST['mobileRatio'], $_POST['format'], $_POST['resolution'], $_POST['withGraphics'], $_POST['withText'], $_POST['version'], $_POST['force']);
+die($p->process());
\ No newline at end of file
diff --git a/app/src/ProcessFile.php b/app/src/ProcessFile.php
new file mode 100644 (file)
index 0000000..076b9fa
--- /dev/null
@@ -0,0 +1,125 @@
+<?php
+
+namespace Fluidbook\Farmer;
+
+use Cubist\PDF\PDFTools;
+use Cubist\Util\Files\Files;
+
+class ProcessFile extends \Fluidbook\Tools\Jobs\ProcessFile
+{
+    protected const DISTANT_ROOT = '/data1/extranet/www/fluidbook/docs/';
+    protected const LOCAL_ROOT = '/files/';
+
+    protected $page;
+    protected $out;
+    protected $force = false;
+    protected $mobileRatio = 1;
+    protected $resolutionRatio = 1;
+    protected $filespath;
+    protected $_job = null;
+
+    public function __construct($out, $page, $resolutionRatio, $mobileRatio, $format = 'jpg', $resolution = 150, $withGraphics = true, $withTexts = true, $version = 'html', $force = false)
+    {
+
+        $this->setOut($out);
+        $this->setPage($page);
+        $this->setForce(!!$force);
+        $this->setResolutionRatio($resolutionRatio);
+        $this->setMobileRatio($mobileRatio);
+        parent::__construct($format, $resolution, $withGraphics, $withTexts, $version);
+    }
+
+    /**
+     * @param float $mobileRatio
+     */
+    public function setMobileRatio(float $mobileRatio): void
+    {
+        $this->mobileRatio = $mobileRatio;
+    }
+
+    /**
+     * @param float $resolutionRatio
+     */
+    public function setResolutionRatio(float $resolutionRatio): void
+    {
+        $this->resolutionRatio = $resolutionRatio;
+    }
+
+    public function getMobileRatio(): float
+    {
+        return $this->mobileRatio;
+    }
+
+    public function getResolutionRatio(): float
+    {
+        return $this->resolutionRatio;
+    }
+
+
+    /**
+     * @return bool
+     */
+    public function isForce(): bool
+    {
+        return $this->force;
+    }
+
+    /**
+     * @param bool $force
+     */
+    public function setForce(bool $force): void
+    {
+        $this->force = $force;
+    }
+
+    /**
+     * @param mixed $page
+     */
+    public function setPage($page): void
+    {
+        $this->page = $page;
+    }
+
+    public function getPage(): int
+    {
+        return $this->page;
+    }
+
+    public function getDistantOut()
+    {
+        return $this->out;
+    }
+
+    public function getLocalOut()
+    {
+        return $this->getOut();
+    }
+
+    public function getOut()
+    {
+        return str_replace(self::DISTANT_ROOT, self::LOCAL_ROOT, $this->getDistantOut());
+    }
+
+    /**
+     * @param mixed $out
+     */
+    public function setOut($out): void
+    {
+        $this->out = $out;
+    }
+
+    public function process()
+    {
+        return str_replace(self::LOCAL_ROOT, self::DISTANT_ROOT, $this->getPath($this->isForce()));
+    }
+
+    public function getSplittedPDFPage()
+    {
+        $res = $this->getOut() . 'pdf/p' . $this->getPage() . '.pdf';
+        if (!file_exists($res)) {
+            PDFTools::split(Files::firstThatExists($this->getOut() . '/crop.pdf', $this->getOut() . '/fixed.pdf', $this->getOut() . '/original.pdf'), $this->getOut() . '/pdf');
+        }
+        return $res;
+    }
+
+}
\ No newline at end of file
diff --git a/bin/fixrights b/bin/fixrights
deleted file mode 100755 (executable)
index fc9165f..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-chown -R fluidbookfarmer:fluidbookfarmer /usr/local/fluidbook_processfarm/*
-chown -R fluidbookfarmer:fluidbookfarmer /usr/local/fluidbook_processfarm/.ssh
-chmod 755 /usr/local/fluidbook_processfarm/bin/*
-chmod 755 /usr/local/fluidbook_processfarm/.ssh
-chmod 600 /usr/local/fluidbook_processfarm/.ssh/id_rsa
-chmod 644 /usr/local/fluidbook_processfarm/.ssh/authorized_keys
\ No newline at end of file
diff --git a/bin/install b/bin/install
deleted file mode 100755 (executable)
index e91fa6e..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-chmod 755 /usr/local/fluidbook_processfarm/bin/*
-groupadd fluidbookfarmer || true
-useradd fluidbookfarmer -g fluidbookfarmer --home /usr/local/fluidbook_processfarm -s /bin/bash || true
-mkdir -p /usr/local/fluidbook_processfarm/files
-/usr/local/fluidbook_processfarm/bin/update
-cp /usr/local/fluidbook_processfarm/etc/sudoers /etc/sudoers.d/fluidbook_processfarm
\ No newline at end of file
diff --git a/bin/installpackages b/bin/installpackages
deleted file mode 100755 (executable)
index 7bc7b6a..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-add-apt-repository -y ppa:ondrej/php
-#apt-get update
-apt-get install -y x11-common pdftk poppler-utils ghostscript netpbm sshfs mupdf-tools php8.1 php8.1-curl php8.1-exif php8.1-xml php8.1-gd php8.1-ssh php8.1-zip libjpeg-turbo-progs zip unzip
-
-if [ ! -f /usr/local/bin/composer ]
-then
-  php -r "copy('https://getcomposer.org/installer', '/tmp/composer-setup.php');"
-  php /tmp/composer-setup.php
-  php -r "unlink('/tmp/composer-setup.php');"
-  mv composer.phar /usr/local/bin/composer
-fi
diff --git a/bin/mount b/bin/mount
deleted file mode 100644 (file)
index b2a6c71..0000000
--- a/bin/mount
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-if mountpoint -q "/usr/local/fluidbook_processfarm/files"; then
-    echo ""
-else
-    sshfs -o uid=`id -u fluidbookfarmer` -o gid=`id -g fluidbookfarmer` root@godzilla.cubedesigners.com:/data/fluidbook/docs /usr/local/fluidbook_processfarm/files
-fi
-
-
-
diff --git a/bin/ping b/bin/ping
deleted file mode 100644 (file)
index d4cc2e1..0000000
--- a/bin/ping
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-/usr/local/fluidbook_processfarm/bin/mount > /dev/null  2>&1
-FILE=/usr/local/fluidbook_processfarm/files/status
-if [ -f "$FILE" ]; then
-    echo "1"
-else
-    echo "0"
-fi
diff --git a/bin/process b/bin/process
deleted file mode 100644 (file)
index 08773fb..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-/usr/local/fluidbook_processfarm/bin/mount
-/usr/bin/php8.1 -f /usr/local/fluidbook_processfarm/bin/process.php -- $1
\ No newline at end of file
diff --git a/bin/process.php b/bin/process.php
deleted file mode 100644 (file)
index 879e2cf..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-
-use Fluidbook\Farmer\Process;
-
-require_once __DIR__ . "/../vendor/autoload.php";
-$params = json_decode(base64_decode($argv[1]), true);
-
-$p = new Process($params['out'], $params['page'], $params['resolutionRatio'], $params['mobileRatio'], $params['format'], $params['resolution'], $params['withGraphics'], $params['withText'], $params['version'], $params['force']);
-echo $p->process();
\ No newline at end of file
diff --git a/bin/update b/bin/update
deleted file mode 100755 (executable)
index adee59f..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-cd /usr/local/fluidbook_processfarm
-git config --global --add safe.directory /usr/local/fluidbook_processfarm
-git stash
-git pull origin master
-chmod 755 /usr/local/fluidbook_processfarm/bin/*
-/usr/local/fluidbook_processfarm/bin/installpackages
-/usr/local/fluidbook_processfarm/bin/fixrights
-export COMPOSER_ALLOW_SUPERUSER=1;composer update
\ No newline at end of file
diff --git a/composer.json b/composer.json
deleted file mode 100644 (file)
index 7b1eff3..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-{
-  "name": "fluidbook/processfarm",
-  "description": "description",
-  "minimum-stability": "dev",
-  "license": "proprietary",
-  "repositories": [
-    {
-      "type": "composer",
-      "url": "https://composer.cubedesigners.com/"
-    }
-  ],
-  "authors": [
-    {
-      "name": "Vincent VANWAELSCAPPEL",
-      "email": "vincent@cubedesigners.com"
-    }
-  ],
-  "autoload": {
-    "psr-4": {
-      "Fluidbook\\Farmer\\": "src"
-    }
-  },
-  "prefer-stable": true,
-  "require": {
-    "php": ">=8.0",
-    "fluidbook/tools": "dev-master"
-  }
-}
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644 (file)
index 0000000..6abc8e6
--- /dev/null
@@ -0,0 +1,16 @@
+version: '3.1'
+services:
+  php:
+    container_name: fluidbook-processfarm
+    build: .
+    working_dir: /application
+    environment:
+      TZ: Europe/Paris
+      HOME: /application
+    volumes:
+      - './app/:/application/'
+      - './ssh/:/root/.ssh/'
+    ports:
+      - '9457:9000'
+    restart: unless-stopped
+    privileged: true
\ No newline at end of file
diff --git a/etc/sudoers b/etc/sudoers
deleted file mode 100644 (file)
index 6a2f108..0000000
+++ /dev/null
@@ -1 +0,0 @@
-fluidbookfarmer    ALL=(ALL) NOPASSWD: /usr/local/fluidbook_processfarm/bin/update
diff --git a/overrides.conf b/overrides.conf
new file mode 100644 (file)
index 0000000..37a1483
--- /dev/null
@@ -0,0 +1,37 @@
+[global]
+; Override default pid file
+pid = /run/php-fpm.pid
+
+; Avoid logs being sent to syslog
+error_log = /proc/self/fd/2
+
+; Set this to php default's max_execution_time to allow children to stop gracefully when fpm is commanded to stop
+; This helps avoiding 502's
+process_control_timeout = 30
+
+; Do not daemonize (eg send process to the background)
+daemonize = no
+
+[www]
+; Access from webserver container is via network, not socket file
+listen = [::]:9000
+
+; Redirect logs to stdout - FPM closes /dev/std* on startup
+access.log = /proc/self/fd/1
+catch_workers_output = yes
+
+; Remove "pool www" decoration from log output (older phpdocker.io containers for php use sed for this)
+decorate_workers_output = no
+
+; Required to allow config-by-environment
+clear_env = no
+
+user = 33
+group = 33
+
+pm = dynamic
+pm.max_children = 80
+pm.start_servers = 24
+pm.min_spare_servers = 20
+pm.max_spare_servers = 40
+pm.max_requests = 1000
diff --git a/src/Process.php b/src/Process.php
deleted file mode 100644 (file)
index 21f13f0..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-<?php
-
-namespace Fluidbook\Farmer;
-
-use Cubist\PDF\PDFTools;
-use Cubist\Util\Files\Files;
-use Fluidbook\Tools\Jobs\ProcessFile;
-
-class Process extends ProcessFile
-{
-    protected const DISTANT_ROOT = '/data1/extranet/www/fluidbook/docs/';
-    protected const LOCAL_ROOT = '/usr/local/fluidbook_processfarm/files/';
-
-    protected $page;
-    protected $out;
-    protected $force = false;
-    protected $mobileRatio = 1;
-    protected $resolutionRatio = 1;
-    protected $filespath;
-    protected $_job = null;
-
-    public function __construct($out, $page, $resolutionRatio, $mobileRatio, $format = 'jpg', $resolution = 150, $withGraphics = true, $withTexts = true, $version = 'html', $force = false)
-    {
-
-        $this->setOut($out);
-        $this->setPage($page);
-        $this->setForce(!!$force);
-        $this->setResolutionRatio($resolutionRatio);
-        $this->setMobileRatio($mobileRatio);
-        parent::__construct($format, $resolution, $withGraphics, $withTexts, $version);
-    }
-
-    /**
-     * @param float $mobileRatio
-     */
-    public function setMobileRatio(float $mobileRatio): void
-    {
-        $this->mobileRatio = $mobileRatio;
-    }
-
-    /**
-     * @param float $resolutionRatio
-     */
-    public function setResolutionRatio(float $resolutionRatio): void
-    {
-        $this->resolutionRatio = $resolutionRatio;
-    }
-
-    public function getMobileRatio(): float
-    {
-        return $this->mobileRatio;
-    }
-
-    public function getResolutionRatio(): float
-    {
-        return $this->resolutionRatio;
-    }
-
-
-    /**
-     * @return bool
-     */
-    public function isForce(): bool
-    {
-        return $this->force;
-    }
-
-    /**
-     * @param bool $force
-     */
-    public function setForce(bool $force): void
-    {
-        $this->force = $force;
-    }
-
-    /**
-     * @param mixed $page
-     */
-    public function setPage($page): void
-    {
-        $this->page = $page;
-    }
-
-    public function getPage(): int
-    {
-        return $this->page;
-    }
-
-    public function getDistantOut()
-    {
-        return $this->out;
-    }
-
-    public function getLocalOut()
-    {
-        return $this->getOut();
-    }
-
-    public function getOut()
-    {
-        return str_replace(self::DISTANT_ROOT, self::LOCAL_ROOT, $this->getDistantOut());
-    }
-
-    /**
-     * @param mixed $out
-     */
-    public function setOut($out): void
-    {
-        $this->out = $out;
-    }
-
-    public function process()
-    {
-        return str_replace(self::LOCAL_ROOT, self::DISTANT_ROOT, $this->getPath($this->isForce()));
-    }
-
-    public function getSplittedPDFPage()
-    {
-        $res = $this->getOut() . 'pdf/p' . $this->getPage() . '.pdf';
-        if (!file_exists($res)) {
-            PDFTools::split(Files::firstThatExists($this->getOut() . '/crop.pdf', $this->getOut() . '/fixed.pdf', $this->getOut() . '/original.pdf'), $this->getOut() . '/pdf');
-        }
-        return $res;
-    }
-
-}
\ No newline at end of file
diff --git a/ssh/id_rsa b/ssh/id_rsa
new file mode 100644 (file)
index 0000000..887177c
--- /dev/null
@@ -0,0 +1,38 @@
+-----BEGIN OPENSSH PRIVATE KEY-----
+b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
+NhAAAAAwEAAQAAAYEAt5L4zbBY/Pw9RtsBOqbjXEuFcBRwET5oCjRcYLQ8vmvoB3A4rsoG
+IWYycvJWKaNNjeyNpFfTKN/p1h9QIp9RW4wD1Rj+VQcLo64hSZH3Dnr++m/LsFbP8RcHSZ
+9znNAJ1b7v9N7b2b9b1VZgBhP0umJvQZgg1VgtqTlXckr7doZpY0qEGmU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rJCl8aQmQeCNQGjBO5mp5VFSAfLl0DaSaLs9pWQM1
+0yFdFK11Pzdk+CJ9icCRcSMvZOBX/F27XvXbYxXy4LUqwCZVQsB51azJNOtNwEXqbxNC9p
+O713DLwIKl+xCLAAAAHXJvb3RAYmF0bWFuLmN1YmVkZXNpZ25lcnMuY29tAQIDBAU=
+-----END OPENSSH PRIVATE KEY-----
diff --git a/ssh/id_rsa.pub b/ssh/id_rsa.pub
new file mode 100644 (file)
index 0000000..f7abdde
--- /dev/null
@@ -0,0 +1 @@
+ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC3kvjNsFj8/D1G2wE6puNcS4VwFHARPmgKNFxgtDy+a+gHcDiuygYhZjJy8lYpo02N7I2kV9Mo3+nWH1Ain1FbjAPVGP5VBwujriFJkfcOev76b8uwVs/xFwdJn3Oc0AnVvu/03tvZv1vVVmAGE/S6Ym9BmCDVWC2pOVdySvt2hmljSoQaZQzPT5DHdwgenbDPU26TmSchFRy/K/a32+juua8P+eceOypi+bzV0K723h4x5teq4rQmsbqFalfUnh0FAYdXbzkTXBfhE/h4D8TkGMkCCgRJSuw5I5SP3XEuDEB24Bzd5HEjAQgrigGE2L697sYEgJkit7WUOQmB1DokgqCc3GgkfUE6/0TKeNeXQv15z7hQ9192Qnjo2Z7qcnebiZrozxo5i7tArJssHekrkMIzF4ujVL0WLLxXt85YAN/AB4A15B1lTM1Cyarp7kFK3mVD7nicJYsCapEgaVa8im6MIJoASg4/qRCrA006LQqC2TyX5wi9mECgJhKCp80= fluidbookfarmer@cubedesigners.com
diff --git a/ssh/known_hosts b/ssh/known_hosts
new file mode 100644 (file)
index 0000000..0ec6ea9
--- /dev/null
@@ -0,0 +1,2 @@
+|1|I3upUS72GkBN0XrvRynC+54Jkjw=|g0RQmSMtyO/SJJur7ff701QpAlk= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBIcf3EkFhhbkL74VV3dG/ZN6X7Do+JDfzw0l7VJX6EmuTM3l2oNdg5jDp4vRHT8c9SKVe/JumeiAkIa/h6fVD4Y=
+|1|Lmv+DVNc45mnhZBQFn+lUcaRRiY=|yOB0mGpn2+50dOkb+stX7Ho5ZwQ= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBIcf3EkFhhbkL74VV3dG/ZN6X7Do+JDfzw0l7VJX6EmuTM3l2oNdg5jDp4vRHT8c9SKVe/JumeiAkIa/h6fVD4Y=
diff --git a/startup b/startup
new file mode 100755 (executable)
index 0000000..93ca79a
--- /dev/null
+++ b/startup
@@ -0,0 +1,3 @@
+#!/bin/sh
+/application/bin/mount
+/usr/sbin/php-fpm8.1 -O
\ No newline at end of file
diff --git a/update b/update
new file mode 100755 (executable)
index 0000000..677f763
--- /dev/null
+++ b/update
@@ -0,0 +1,13 @@
+#!/bin/bash
+cd /docker/fluidbook-processfarm
+git config --global --add safe.directory /docker/fluidbook-processfarm
+git stash
+git pull origin master
+chmod 755 /docker/fluidbook-processfarm/app/bin/*
+chmod 755 /docker/fluidbook-processfarm/ssh
+chmod 600 /docker/fluidbook-processfarm/ssh/id_rsa
+chmod 644 /docker/fluidbook-processfarm/ssh/authorized_keys
+DOCKER_BUILDKIT=1 docker compose build
+docker compose down
+docker compose up -d
+docker exec fluidbook-processfarm composer update
\ No newline at end of file