From 805a34c9d621cf39c04ca799a5df26ac85dcfd56 Mon Sep 17 00:00:00 2001 From: ngosang Date: Sun, 30 May 2021 12:16:34 +0200 Subject: [PATCH] Provide reference Systemd unit file. Resolves #72 --- README.md | 6 +++++- build-binaries.js | 5 ++++- flaresolverr.service | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 flaresolverr.service diff --git a/README.md b/README.md index 4756b81..c3b28c8 100644 --- a/README.md +++ b/README.md @@ -67,13 +67,17 @@ This is the recommended way for Windows users. ### From source code -This is the recommended way for MacOS users and for developers. +This is the recommended way for macOS users and for developers. * Install [NodeJS](https://nodejs.org/) * Clone this repository and open a shell in that path * Run `npm install` command to install FlareSolverr dependencies * Run `npm run build` command to compile TypeScript code * Run `npm start` command to start FlareSolverr +### Systemd service + +We provide an example Systemd unit file `flaresolverr.service` as reference. You have to modify the file to suit your needs: paths, user and environment variables. + ## Usage Example request: diff --git a/build-binaries.js b/build-binaries.js index 1614b1c..3e00f70 100644 --- a/build-binaries.js +++ b/build-binaries.js @@ -40,7 +40,7 @@ const version = 'v' + require('./package.json').version; // generate executables console.log('Generating executables...') if (fs.existsSync('bin')) { - fs.rmdirSync('bin', { recursive: true }) + fs.rmSync('bin', { recursive: true }) } execSync('pkg -t node14-win-x64,node14-linux-x64 --out-path bin .') // execSync('pkg -t node14-win-x64,node14-mac-x64,node14-linux-x64 --out-path bin .') @@ -76,6 +76,9 @@ const version = 'v' + require('./package.json').version; archive.file('LICENSE', { name: 'flaresolverr/' + os.fsLicenseName }) archive.file('bin/' + os.fsExec, { name: 'flaresolverr/' + os.fsZipExec }) archive.directory('bin/puppeteer/' + os.platform + '-' + os.version + '/' + os.chromeFolder, 'flaresolverr/chrome') + if (os.platform === 'linux') { + archive.file('flaresolverr.service', { name: 'flaresolverr/flaresolverr.service' }) + } await archive.finalize() } diff --git a/flaresolverr.service b/flaresolverr.service new file mode 100644 index 0000000..057eeee --- /dev/null +++ b/flaresolverr.service @@ -0,0 +1,19 @@ +[Unit] +Description=FlareSolverr +After=network.target + +[Service] +SyslogIdentifier=flaresolverr +Restart=always +RestartSec=5 +Type=simple +User=flaresolverr +Group=flaresolverr +Environment="LOG_LEVEL=info" +Environment="CAPTCHA_SOLVER=none" +WorkingDirectory=/opt/flaresolverr +ExecStart=/opt/flaresolverr/flaresolverr +TimeoutStopSec=30 + +[Install] +WantedBy=multi-user.target