So basically I have an app that uses selenium and seleniumwire to do some stuff. I'm using chromedriver. The installed chrome version (91.0.4472.114) and webdriver version (91.0.4472.101) are basically the same. When I'm starting the app with the terminal by issuing the command:
gunicorn --workers 3 --bind 0.0.0.0:5000 wsgi:create_app\(\) --preload
Everything works fine. But when I'm trying to use systemd to launch the app in the background I get the error I mentioned in the title (DevToolsActivePort file doesn't exist).
My systemd unit file:
[Unit]
Description=Gunicorn instance to serve some app
After=network.target
[Service]
User=myuser
Group=www-data
WorkingDirectory=/home/myuser/path-to-my-app
Environment="PATH=/home/myuser/path-to-my-app/venv/bin"
ExecStart=/home/myuser/path-to-my-app/venv/bin/gunicorn --workers 3 --bind unix:myapp.sock -m 007 wsgi:create_app() --preload
[Install]
WantedBy=multi-user.target
My chromedriver options:
user_agent = 'Mozilla/5.0 (X11; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0'
options_args = [
    f'user-agent={user_agent}',
    '--window-size=1920,1080',
    '--ignore-certificate-errors',
    '--allow-running-insecure-content',
    '--disable-extensions',
    '--start-maximized',
    '--disable-gpu',
    '--disable-dev-shm-usage',
    '--no-sandbox'
]
options = webdriver.ChromeOptions()
options.headless = True
for arg in options_args:
    options.add_argument(arg)
I tried all the solutions I could find on SO (mainly this) and other websites (which include setting the --no-sandbox and --disable-dev-shm-usage options) but without any luck. Also, setting --remote-debugging-port=xxx didn't help.
As a workaround, I'm currently using nohup to keep the app running after I quit SSH session but this is an unacceptable solution for me.
I know that this question is probably a duplicate but I couldn't find any solution that works for me. I'm happy to include all the details you need to solve this problem.
