Setup Selenium Hub as a Service in Ubuntu 16.04

Setup Selenium Hub as a Service in Ubuntu 16.04:

If you are still on Ubuntu 14.04, kindly refer to this link.

Setting up selenium hub as a service saves you from the tedious task of running long commands to start and restart the selenium server several times during your development. Also, this ensures that you grid is always up and running and you don't have to bring it back up every time your machine\automation server gets rebooted.
  • Run the below command to create selenium service file. Enter your password if asked. 
sudo nano /etc/systemd/system/selenium.service
  • Paste the below content in this config file. 
[Unit]
Description=run Selenium Server as hub

[Service]
ExecStart=/usr/bin/java -jar /opt/softwares/selenium-server.jar -role hub -port 4444

[Install]
WantedBy=multi-user.target



  • Press Ctrl+X followed by Y and Enter to confirm saving the changes to the file
  • Now reload the systemd process so that it can reference to the new file you created
sudo systemctl daemon-reload
  • Enable the new selenium service we created by running the command below so that it gets automatically started at boot
sudo systemctl enable selenium.service
  • Run the below command to start the selenium hub service.
sudo systemctl start selenium.service



Tips:
  • Every time you want to restart the grid you can just run sudo systemctl restart selenium.service
  • You can also configure any additional parameters you might have along with you java -jar /opt/softwares/selenium-server.jar -role hub -port 4444 command during creation of selenium.conf file.


Comments

Popular posts from this blog

Get rid of "Timed out receiving message from renderer"

Selenium Grid using Zalenium

Selenium - How to initialize Chrome and Firefox WebDriver