I am using pyhtml2pdf for converting HTML to PDF which has a requirement of Chrome headless.
converter.convert(f'file:///{path}', pdf_file_path)
When the server is run as python manage.py runserver there is no issue.
But when the django is run as a service it throws and error regarding split with chrome.py :
Exception occurred in file ‘/var/www/myProject/env/lib/python3.11/site-packages/webdriver_manager/drivers/chrome.py’, line 64: ‘NoneType’ object has no attribute ‘split’.
Our service :
cat /etc/systemd/system/myProject.service
[Unit]
Description=myProject_0 project
After=network.target
[Service]
User=root
Group=root
WorkingDirectory=/var/www/myProject
Environment="PATH=/var/www/myProject/env/bin/activate"
ExecStart=/bin/bash -c 'source /var/www/myProject/env/bin/activate && python manage.py runserver'
StandardOutput=append:/var/log/myProject/myProject.log
StandardError=append:/var/log/myProject/myProject_error.log
[Install]
WantedBy=multi-user.target
We troubleshooted this for a long time and found out then when run as python manage.py runserver on our Ubuntu 20.04 server on an Azure VM this chrome.py error doesn’t throw up.
Where did we go wrong ?