github.com/bazelbuild/rules_webtesting@v0.2.0/go/wtl/service/wsl/wsl.go (about) 1 // Copyright 2018 Google Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // Package wsl provides a Service for launching WebDriver Server Light (WSL). 16 package wsl 17 18 import ( 19 "time" 20 21 "github.com/bazelbuild/rules_webtesting/go/errors" 22 "github.com/bazelbuild/rules_webtesting/go/metadata" 23 "github.com/bazelbuild/rules_webtesting/go/wtl/diagnostics" 24 "github.com/bazelbuild/rules_webtesting/go/wtl/service" 25 ) 26 27 const ( 28 compName = "WSL Service" 29 wslNamedFile = "WEBDRIVER_SERVER_LIGHT" 30 ) 31 32 // New creates a new service.Server instance that manages chromedriver. 33 func New(d diagnostics.Diagnostics, m *metadata.Metadata) (*service.Server, error) { 34 wslPath, err := m.GetFilePath(wslNamedFile) 35 if err != nil { 36 return nil, errors.New(compName, err) 37 } 38 39 server, err := service.NewServer( 40 compName, 41 d, 42 wslPath, 43 "http://%s/healthz", 44 false, 45 1*time.Second, 46 nil, 47 "--port={port}") 48 if err != nil { 49 return nil, err 50 } 51 return server, nil 52 }