Skip to content

Instantly share code, notes, and snippets.

@kapb14
Created June 15, 2018 17:17
Show Gist options
  • Select an option

  • Save kapb14/752912de03bba97065cfdd58bec32422 to your computer and use it in GitHub Desktop.

Select an option

Save kapb14/752912de03bba97065cfdd58bec32422 to your computer and use it in GitHub Desktop.
Selenium Standalone Server as a systemd Service
# /etc/systemd/system/selenium.service
[Unit]
Description=Selenium Standalone Server
Requires=xvfb.service
After=xvfb.service
[Service]
Type=simple
User=www-data
PIDFile=/opt/selenium/selenium.pid
Environment=DISPLAY=:99
# Restart=always
# RestartSec=10
ExecStart=/bin/java -jar \
-Dwebdriver.chrome.bin=/bin/google-chrome \
-Dwebdriver.chrome.driver=/opt/selenium/chromedriver \
-Dwebdriver.chrome.logfile=/opt/selenium/log/chrome.log \
/opt/selenium/selenium-server.jar \
-log /opt/selenium/log/selenium.log \
-role standalone \
-port 4444
ExecStartPost=-/bin/bash -c '/bin/pgrep -u www-data -f selenium | /bin/head -n 1 > /opt/selenium/selenium.pid'
ExecStop=/bin/kill $(/bin/cat /opt/selenium/selenium.pid)
[Install]
WantedBy=multi-user.target
Alias=selenium-server
# /etc/systemd/system/xvfb.service
[Unit]
Description=X virtual framebuffer
[Service]
Type=simple
User=root
ExecStart=/bin/Xvfb :99 -ac
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment