Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #198 from vania-pooh/master
Browse files Browse the repository at this point in the history
Disabling logs and SeLinux workaround
  • Loading branch information
aandryashin authored Oct 30, 2018
2 parents 93a0f60 + 0bf53e0 commit 3d06531
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 25 deletions.
21 changes: 12 additions & 9 deletions cmd/selenoid.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var (
port uint16
uiPort uint16
userNS string
disableLogs bool
)

func init() {
Expand Down Expand Up @@ -157,20 +158,22 @@ func initFlags() {
c.Flags().StringVarP(&args, "args", "g", "", "additional service arguments (e.g. \"-limit 5\")")
c.Flags().StringVarP(&env, "env", "e", "", "override service environment variables (e.g. \"KEY1=value1 KEY2=value2\")")
c.Flags().StringVarP(&userNS, "userns", "", "", "override user namespace, similarly to \"docker run --userns host ...\" (Docker only)")
c.Flags().BoolVarP(&disableLogs, "disable-logs", "", false, "start with log saving feature disabled")
}
}

func createLifecycle(configDir string, port uint16) (*selenoid.Lifecycle, error) {
config := selenoid.LifecycleConfig{
Quiet: quiet,
Force: force,
ConfigDir: configDir,
Browsers: browsers,
BrowserEnv: browserEnv,
Download: !skipDownload,
Args: args,
Env: env,
Port: int(port),
Quiet: quiet,
Force: force,
ConfigDir: configDir,
Browsers: browsers,
BrowserEnv: browserEnv,
Download: !skipDownload,
Args: args,
Env: env,
Port: int(port),
DisableLogs: disableLogs,

LastVersions: lastVersions,
RegistryUrl: registry,
Expand Down
4 changes: 4 additions & 0 deletions selenoid/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ type UserNSAware struct {
UserNS string
}

type LogsAware struct {
DisableLogs bool
}

const (
SelenoidDefaultPort = 4444
SelenoidUIDefaultPort = 8080
Expand Down
12 changes: 7 additions & 5 deletions selenoid/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ type DockerConfigurator struct {
BrowserEnvAware
PortAware
UserNSAware
LogsAware
LastVersions int
Pull bool
RegistryUrl string
Expand All @@ -96,6 +97,7 @@ func NewDockerConfigurator(config *LifecycleConfig) (*DockerConfigurator, error)
BrowserEnvAware: BrowserEnvAware{BrowserEnv: config.BrowserEnv},
PortAware: PortAware{Port: config.Port},
UserNSAware: UserNSAware{UserNS: config.UserNS},
LogsAware: LogsAware{DisableLogs: config.DisableLogs},
RegistryUrl: config.RegistryUrl,
LastVersions: config.LastVersions,
Tmpfs: config.Tmpfs,
Expand Down Expand Up @@ -642,16 +644,16 @@ func (c *DockerConfigurator) Start() error {
videoConfigDir := getVolumeConfigDir(filepath.Join(c.ConfigDir, videoDirName), append(selenoidConfigDirElem, videoDirName))
logsConfigDir := getVolumeConfigDir(filepath.Join(c.ConfigDir, logsDirName), append(selenoidConfigDirElem, logsDirName))
volumes := []string{
fmt.Sprintf("%s:/etc/selenoid:ro", volumeConfigDir),
fmt.Sprintf("%s:/opt/selenoid/video", videoConfigDir),
fmt.Sprintf("%s:/opt/selenoid/logs", logsConfigDir),
fmt.Sprintf("%s:/etc/selenoid:ro,Z", volumeConfigDir),
fmt.Sprintf("%s:/opt/selenoid/video:Z", videoConfigDir),
fmt.Sprintf("%s:/opt/selenoid/logs:Z", logsConfigDir),
}
const dockerSocket = "/var/run/docker.sock"
if c.isDockerForWindows() {
//With two slashes. See https://stackoverflow.com/questions/36765138/bind-to-docker-socket-on-windows
volumes = append(volumes, fmt.Sprintf("/%s:%s", dockerSocket, dockerSocket))
} else if fileExists(dockerSocket) {
volumes = append(volumes, fmt.Sprintf("%s:%s", dockerSocket, dockerSocket))
volumes = append(volumes, fmt.Sprintf("%s:%s:Z", dockerSocket, dockerSocket))
}

cmd := []string{}
Expand All @@ -666,7 +668,7 @@ func (c *DockerConfigurator) Start() error {
cmd = append(cmd, "-video-output-dir", "/opt/selenoid/video/", "-video-recorder-image", videoRecorderImage)
}

if !contains(cmd, "-log-output-dir") && isLogSavingSupported(c.Logger, c.Version) {
if !c.DisableLogs && !contains(cmd, "-log-output-dir") && isLogSavingSupported(c.Logger, c.Version) {
cmd = append(cmd, "-log-output-dir", "/opt/selenoid/logs/")
}

Expand Down
4 changes: 3 additions & 1 deletion selenoid/drivers.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type DriversConfigurator struct {
BrowserEnvAware
PortAware
RequestedBrowsersAware
LogsAware
Browsers string
BrowsersJsonUrl string

Expand All @@ -85,6 +86,7 @@ func NewDriversConfigurator(config *LifecycleConfig) *DriversConfigurator {
PortAware: PortAware{Port: config.Port},
DownloadAware: DownloadAware{DownloadNeeded: config.Download},
RequestedBrowsersAware: RequestedBrowsersAware{Browsers: config.Browsers},
LogsAware: LogsAware{DisableLogs: config.DisableLogs},
BrowsersJsonUrl: config.BrowsersJsonUrl,
Browsers: config.Browsers,
GithubBaseUrl: config.GithubBaseUrl,
Expand Down Expand Up @@ -584,7 +586,7 @@ func (d *DriversConfigurator) Start() error {
if !contains(args, "-disable-docker") {
args = append(args, "-disable-docker")
}
if !contains(args, "-log-output-dir") && isLogSavingSupported(d.Logger, d.Version) {
if !d.DisableLogs && !contains(args, "-log-output-dir") && isLogSavingSupported(d.Logger, d.Version) {
logsConfigDir := getVolumeConfigDir(filepath.Join(d.ConfigDir, logsDirName), append(selenoidConfigDirElem, logsDirName))
args = append(args, "-log-output-dir", logsConfigDir)
}
Expand Down
21 changes: 11 additions & 10 deletions selenoid/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ import (
)

type LifecycleConfig struct {
Quiet bool
Force bool
ConfigDir string
Browsers string
BrowserEnv string
Download bool
Args string
Env string
Version string
Port int
Quiet bool
Force bool
ConfigDir string
Browsers string
BrowserEnv string
Download bool
Args string
Env string
Version string
Port int
DisableLogs bool

// Docker specific
LastVersions int
Expand Down

0 comments on commit 3d06531

Please sign in to comment.