Often an administrator will want to start Sauce Connect Proxy as a Windows service. While Sauce Connect is not currently set up to be a Windows service, it can be made to run as one with the help of some external tools. This article describes how to set this up, but note that our example uses a third party tool. We provide this only as an example rather than a supported product from Sauce Labs.
What you will need
- A copy of the latest version of Sauce Connect Proxy from https://wiki.saucelabs.com/display/DOCS/Sauce+Connect+Proxy
- A Windows Service manager. In the example here we use NSSM.
Steps to Implement
- Download NSSM (http://nssm.cc/download) and extract the
- Open the command prompt as Administrator, then navigate to the NSSM directory via the command line.
- Create the service with this command:
nssm install SauceConnect1 "C:\<path_to_sauceconnect_client>\bin\sc.exe" "-u <username>" "-k <access key>" "--tunnel-identifier TUNNELNAME" "--no-remove-colliding-tunnels" "--pidfile C:\Windows\Temp\pid1.log" "-P 4447"
- Open up the Windows Services Manager and make sure the new services (named
SauceConnect1) are set to start manually.
- Create a batch file (for example
restartSC.bat) that contains these lines:
NET STOP SauceConnect1
NET START SauceConnect1
- Open the Windows Task Scheduler and set it to call
restartSC.batonce a day or at any other period of time.
Once you've set all these up, the tunnel should restart itself daily at the time of your choosing.