에러
chromedriver devtoolsactiveport file doesn't exist
그냥 실행하면 정상 작동하지만
systemd 로 service 등록 후에 실행하면 에러 발생
원인
systemd service로 등록을 하면 conda env 환경을 못 찾는 것으로 판단된다.
해결
systemd 스크립트에서
Environment 사용하면 에러 발생하므로
Environment 주석처리하고 ExecStart 를 풀경로로 적는다.
[Unit]
Description= Crawler
After=network.target
[Service]
User=sysadm
Group=sysadm
WorkingDirectory=/Project/Crawler
#Environment="PATH=/anaconda3/envs/crawler/bin"
ExecStart=/anaconda3/envs/crwaler/bin/python /Project/Crawler/crwaler.py
[Install]
WantedBy=multi-user.target
다른 해결 방법
selenium chrome option 부분을 추가한다.
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument("--single-process")
chrome_options.add_argument("--disable-dev-shm-usage")
근본적으론 이 해결 방법이 맞으나
소스 코드 수정해서 올리기 힘든 경우에 간단하게 해결 할 수 있는 방법을 적어보았다.
'Python' 카테고리의 다른 글
[크롤링] 디시인사이드 갤러리 공지사항 태그 제거 크롤링 (0) | 2023.07.26 |
---|---|
[Error] bad operand type for unary -: 'CursorResult' (0) | 2023.07.26 |
[Selenium] Can not find chromedirver fo currently installed chrome version. (0) | 2023.07.24 |
[python] tuple 에서 특정 field로 value값 추출 (0) | 2023.06.28 |
리눅스에서 .env를 읽지 못하는 경우(vscode에서는 됨) (0) | 2023.06.27 |