From ebbe786052bae1f2cbb08f4a009590dbc41c9ce0 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski <ayufan@ayufan.eu> Date: Fri, 25 Mar 2016 14:16:53 +0100 Subject: [PATCH] Update the OSX service instruction --- commands/multi.go | 2 +- commands/service.go | 49 ++++++++++++++------------------ docs/faq/README.md | 33 +++++++++++++++++++++ docs/install/docker.md | 2 ++ docs/install/freebsd.md | 4 ++- docs/install/linux-manually.md | 2 ++ docs/install/linux-repository.md | 2 ++ docs/install/osx.md | 33 ++++++++++++++++++++- docs/install/windows.md | 2 ++ 9 files changed, 99 insertions(+), 30 deletions(-) diff --git a/commands/multi.go b/commands/multi.go index 7be39fd70..e82ae332e 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 a99d0dfaf..2c1d8cb81 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 0c8e13908..d03298c65 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 0d5e97dd5..90817a676 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 773259154..a7eb11dc0 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 6f034617b..5489e242f 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 63299d601..a4dc1cd8a 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 cbbf9bbd5..09f6383dc 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 3b50cdbda..0ac2dba22 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 -- GitLab