diff --git a/commands/multi.go b/commands/multi.go index 7be39fd70bb7ce01899f9447f4a68f764918c2f2..e82ae332eb8620d1c12a38d1cbc2dca24772cc82 100644 --- a/commands/multi.go +++ b/commands/multi.go @@ -212,7 +212,7 @@ func (mr *RunCommand) Start(s service.Service) error { err := mr.loadConfig() if err != nil { - panic(err) + return err } // Start should not block. Do the actual work async. diff --git a/commands/service.go b/commands/service.go index a99d0dfaff55dfba2a20ce6939d76cb290bd416a..2c1d8cb81ecc61e25acfd1da7d75cbb55a5fc311 100644 --- a/commands/service.go +++ b/commands/service.go @@ -90,7 +90,7 @@ func runServiceStatus(displayName string, s service.Service, c *cli.Context) err return nil } -func getServiceArguments(c *cli.Context, isUserService bool) (arguments []string) { +func getServiceArguments(c *cli.Context) (arguments []string) { if wd := c.String("working-directory"); wd != "" { arguments = append(arguments, "--working-directory", wd) } @@ -103,53 +103,48 @@ func getServiceArguments(c *cli.Context, isUserService bool) (arguments []string arguments = append(arguments, "--service", sn) } - if user := c.String("user"); !isUserService && user != "" { - arguments = append(arguments, "--user", user) - } - arguments = append(arguments, "--syslog") return } func createServiceConfig(c *cli.Context) (svcConfig *service.Config) { - // detect whether we want to install as user service or system service - isUserService := os.Getuid() != 0 - if runtime.GOOS == "windows" { - isUserService = true - } - - // when installing service as system wide service don't specify username for service - serviceUserName := c.String("user") - if !isUserService { - serviceUserName = "" - } - - if isUserService && runtime.GOOS == "linux" { - logrus.Fatal("Please run the commands as root") - } - svcConfig = &service.Config{ Name: c.String("service"), DisplayName: c.String("service"), Description: defaultDescription, Arguments: []string{"run"}, - UserName: serviceUserName, } - svcConfig.Arguments = append(svcConfig.Arguments, getServiceArguments(c, isUserService)...) + svcConfig.Arguments = append(svcConfig.Arguments, getServiceArguments(c)...) switch runtime.GOOS { + case "linux": + if os.Getuid() != 0 { + logrus.Fatal("Please run the commands as root") + } + if user := c.String("user"); user != "" { + svcConfig.Arguments = append(svcConfig.Arguments, "--user", user) + } + case "darwin": svcConfig.Option = service.KeyValue{ - "KeepAlive": true, - "RunAtLoad": true, - "SessionCreate": true, - "UserService": isUserService, + "KeepAlive": true, + "RunAtLoad": true, + "UserService": os.Getuid() == 0, + } + + if user := c.String("user"); user != "" { + if os.Getuid() == 0 { + svcConfig.Arguments = append(svcConfig.Arguments, "--user", user) + } else { + logrus.Fatalln("The --user is not supported for non-root users") + } } case "windows": svcConfig.Option = service.KeyValue{ "Password": c.String("password"), } + svcConfig.UserName = c.String("user") } return } diff --git a/docs/faq/README.md b/docs/faq/README.md index 0c8e139088c43cd051a5dc13f08e93b22fde6120..d03298c654c39bf2e5ac1c4163390830a7559403 100644 --- a/docs/faq/README.md +++ b/docs/faq/README.md @@ -127,3 +127,36 @@ See [an example of a user issue][1105]. [omnibus-ext-nginx]: http://doc.gitlab.com/omnibus/settings/nginx.html#using-a-non-bundled-web-server [recipes]: https://gitlab.com/gitlab-org/gitlab-recipes/tree/master/web-server [1105]: https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/issues/1105 + +## 11. Runner cannot be installed on OSX, because of `"launchctl" failed: exit status 112, Could not find domain for`: + +Make sure that you manage GitLab Runner service from the GUI Terminal application, not the SSH connection. + +## 12. Runner is stuck on `Failed to authorize rights (0x1) with status: -60007.` when using OSX: + +There are two problems why this happens: +1. Make sure that your user can do UI interactions. + + ``` + DevToolsSecurity -enable + sudo security authorizationdb remove system.privilege.taskport is-developer + ``` + + The first command enables access to developer tools for your user. + + Second command allows the user, member of developer group to do UI interactions, ex. run iOS simulator. + +2. Make sure that your runner service doesn't use `SessionCreate = true`. +Previously when running GitLab Runner as an service we were creating the `LaunchAgents` with `SessionCreate`. +At that point (`Mavericks`) it was the only solution to make Code Signing work, +but recently with introduction of `El Capitan` OSX introduced a lot of new security features which did change this behaviour. +Since GitLab Runner 1.1 when creating a `LaunchAgent` we don't set the `SessionCreate`. +However, in order to upgrade you need to manually reinstall the `LaunchAgent` script: + + ``` + gitlab-ci-multi-runner uninstall + gitlab-ci-multi-runner install + gitlab-ci-multi-runner start + ``` + + Then you can verify that `~/Library/LaunchAgents/gitlab-runner.plist` have `SessionCreate` set to `false`. diff --git a/docs/install/docker.md b/docs/install/docker.md index 0d5e97dd5e4f0d77fa7020f7eece37b53acd09ce..90817a676522986b8566ad8db9b6fefec2949707 100644 --- a/docs/install/docker.md +++ b/docs/install/docker.md @@ -62,6 +62,8 @@ running already the config should be automatically reloaded! The runner should is started already and you are ready to build your projects! +Make sure that you read the [FAQ](../faq/README.md) section which describes most common problems with the GitLab Runner. + ### Update Pull the latest version: diff --git a/docs/install/freebsd.md b/docs/install/freebsd.md index 77325915423e3761713555eb505388048b317f68..a7eb11dc058648f3c9c3ef956b6c45ec0b431791 100644 --- a/docs/install/freebsd.md +++ b/docs/install/freebsd.md @@ -42,4 +42,6 @@ gitlab-ci-multi-runner run Voila! Runner is currently running, but it will not start automatically after system reboot because BSD startup service is not supported. -**The FreeBSD version is also availble from [Bleeding edge](bleeding-edge.md)** \ No newline at end of file +**The FreeBSD version is also available from [Bleeding edge](bleeding-edge.md)** + +Make sure that you read the [FAQ](../faq/README.md) section which describes most common problems with the GitLab Runner. diff --git a/docs/install/linux-manually.md b/docs/install/linux-manually.md index 6f034617b464023d241a961bf7af03f5b2815651..5489e242ff77df2025ec4628a04e317e4ea8e1a3 100644 --- a/docs/install/linux-manually.md +++ b/docs/install/linux-manually.md @@ -66,3 +66,5 @@ Start the service: ```bash sudo gitlab-ci-multi-runner start ``` + +Make sure that you read the [FAQ](../faq/README.md) section which describes most common problems with the GitLab Runner. diff --git a/docs/install/linux-repository.md b/docs/install/linux-repository.md index 63299d601b01cb6f6919573497bd996ca9f373bd..a4dc1cd8aad07148af257207d49265557662ce14 100644 --- a/docs/install/linux-repository.md +++ b/docs/install/linux-repository.md @@ -50,6 +50,8 @@ running already the config should be automatically reloaded! The runner should be started already and you are ready to build your projects! +Make sure that you read the [FAQ](../faq/README.md) section which describes most common problems with the GitLab Runner. + ### Update Simply execute to install latest version: diff --git a/docs/install/osx.md b/docs/install/osx.md index cbbf9bbd5cebbcea9f74e7a220cd18112b1865c9..09f6383dcdc0a908a0180fffffdfe38fee6e85cf 100644 --- a/docs/install/osx.md +++ b/docs/install/osx.md @@ -69,4 +69,35 @@ Start the service: ```bash gitlab-ci-multi-runner start -``` \ No newline at end of file +``` + +Make sure that you read the [FAQ](../faq/README.md) section which describes most common problems with the GitLab Runner. + +### Limitations on OSX + +Currently the only proven to work mode for OSX is running service in user-mode. + +**The service needs to be installed from Terminal running GUI interface as your user. +Only then you will be able to manage the service.** + +Since the service will be running only when the user is logged in you should enable auto-logging on your OSX machine. + +The service will be launched as one of `LaunchAgents`. +By using `LaunchAgents` the builds will be able to do UI interactions, +making it possible to run and test on iOS simulator and also do process instrumentations. + +Worth to note is that OSX also have the `LaunchDaemons`, the services running completely in background. +The `LaunchDaemons` are run on system startup, but they don't have the same access to UI interactions as `LaunchAgents`. +You can try to run service as `LaunchDaemon`, but this mode of operation as of now is not supported. + +You can verify that runner created service configuration after the executing `install` command +by checking the `~user/Library/LaunchAgents/gitlab-runner.plist` file. + +### Upgrade the service file + +In order to upgrade the `LaunchAgent` configuration you need to uninstall and install the service: +``` +gitlab-ci-multi-runner uninstall +gitlab-ci-multi-runner install +gitlab-ci-multi-runner start +``` diff --git a/docs/install/windows.md b/docs/install/windows.md index 3b50cdbdae0588c8ef9f242a03092363f82d825b..0ac2dba22ae7a12d713e70b45388893dbb15b01d 100644 --- a/docs/install/windows.md +++ b/docs/install/windows.md @@ -60,6 +60,8 @@ Start service: gitlab-ci-multi-runner start ``` +Make sure that you read the [FAQ](../faq/README.md) section which describes most common problems with the GitLab Runner. + [x86]: https://gitlab-ci-multi-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-ci-multi-runner-windows-386.exe [amd64]: https://gitlab-ci-multi-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-ci-multi-runner-windows-amd64.exe [prompt]: http://pcsupport.about.com/od/windows-8/a/elevated-command-prompt-windows-8.htm