From 3a58d675299d0f314ae35c6f4fc92d92c1f0fb71 Mon Sep 17 00:00:00 2001 From: sco-gar <111551064+sco-gar@users.noreply.github.com> Date: Wed, 29 Mar 2023 00:21:10 +0100 Subject: [PATCH] Added instructions for Pip based install - original credit to /u/aman207 --- Playwright-content-fetcher.md | 85 ++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 1 deletion(-) diff --git a/Playwright-content-fetcher.md b/Playwright-content-fetcher.md index 006657f..1c6c127 100644 --- a/Playwright-content-fetcher.md +++ b/Playwright-content-fetcher.md @@ -30,7 +30,90 @@ docker run -d --name browserless \ ``` ## Pip install based - @todo +This assumes Playwright is being installed and run on the same server as changedection.io - if running on a different server adjust changedetection.io variables accordingly - ensure firewall ports are open. Process below tested and working on Debian 11. + +Install the nodejs 16 repo +``` +curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - +``` + +Install the dependencies +``` +sudo apt install python3-dev python3-pip nodejs build-essential ca-certificates curl dumb-init ffmpeg fontconfig fonts-freefont-ttf fonts-gfs-neohellenic fonts-indic fonts-ipafont-gothic fonts-kacst fonts-liberation fonts-noto-cjk fonts-noto-color-emoji fonts-roboto fonts-thai-tlwg fonts-ubuntu fonts-wqy-zenhei gconf-service git libappindicator1 libappindicator3-1 libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm-dev libgbm1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 locales lsb-release msttcorefonts pdftk unzip wget xdg-utils xvfb +``` + +Install playwright via Pip +``` +python3 -m pip install playwright +``` + +Clone this git repo to a folder of your choice (eg. /opt/) +``` +git clone [https://github.com/browserless/chrome /opt/browserless](https://github.com/browserless/chrome%20/opt/browserless) +``` + +cd into folder git cloned into then run +``` +npm install +npm run build +npm prune production +``` + + +Systemd service configs (/etc/systemd/system/) + +Example browserless.service: +``` +[Unit] +Description=browserless service +After=network.target + +[Service] +Environment=APP_DIR=/opt/browserless +Environment=PLAYWRIGHT_BROWSERS_PATH=/opt/browserless +Environment=CONNECTION_TIMEOUT=60000 +Environment=HOST=127.0.0.1 +Environment=LANG="C.UTF-8" +Environment=NODE_ENV=production +Environment=PORT=3000 +Environment=WORKSPACE_DIR=/opt/browserless/workspace +WorkingDirectory=/opt/browserless +ExecStart=/opt/browserless/start.sh +SyslogIdentifier=browserless + +[Install] +WantedBy=default.target +``` + +Example changedetection.service +``` +[Unit] +Description=changedetection.io service +After=network.target browserless.service +Wants=browserless.service + +[Service] +Environment=PLAYWRIGHT_DRIVER_URL=ws://127.0.0.1:3000/?stealth=1&--disable-web-security=true +ExecStart=/usr/local/bin/changedetection.io -d /opt/change-detection -p 80 +SyslogIdentifier=change-detection + +[Install] +WantedBy=default.target +``` + + +Enable services: +``` +systemctl enable browserless.service +systemctl enable changedetection.service +``` +Manual control: +``` +systemctl start [service] +systemctl stop [service] +``` + + ## Playwright memory leak