diff --git a/README.md b/README.md index 84d1196..1bc93c4 100644 --- a/README.md +++ b/README.md @@ -17,18 +17,35 @@ You can start and stop the runner as a process, or use 'service' to install it a ``` Usage: - runner create [] [flags] + runner [command] + +Available Commands: + completion Generate the autocompletion script for the specified shell + create Create a new runner with the given options + help Help about any command + remove Remove configuration and runner + service Manage the runner with a machine-level service + start Start an already configured runner as a process in your current context + stop Stop runner processes that are currently running in a local process Flags: - -e, --enterprise string Add the runner at the Enterprise level with the enterprise's name - -g, --group string Runner group to add the runner to, defaults to 'Default' - -h, --help help for create - -l, --labels string Comma-separated list of labels to add to the runner - -o, --org string Add the runner at the Organization level with the organization's name - -s, --skip-download Skip downloading the runner binary, because you already have one extracted in the current directory - -Global Flags: + -h, --help help for runner -N, --name string Name of the runner, creates a folder and a runner with this name, defualts to 'actions-runner' When you set a name, you will need to use that name for all subsequent commands commands to that runner (default "actions-runner") -R, --repo string Repository to use in OWNER/REPO format, defaults to the current repository + +Usage: + runner create [] [flags] + +Flags: + -e, --enterprise string Add the runner at the Enterprise level with the enterprise's name + -g, --group string Runner group to add the runner to, defaults to 'Default' + -h, --help help for create + -l, --labels string Comma-separated list of labels to add to the runner + -o, --org string Add the runner at the Organization level with the organization's name + -r, --replace Replace any existing runner with the same name + -s, --skip-download Skip downloading the runner binary, because you already have one extracted in the current directory + -w, --windows-service gh runner service create Install the runner as a Windows Service (Windows only, requires admin privileges, use gh runner service create on linux and MacOS) + --windowslogonaccount string The logon account to use for the service (Windows only) + --windowslogonpassword string The logon password to use for the service (Windows only) ``` diff --git a/main.go b/main.go index 9ad7571..e7bca8f 100644 --- a/main.go +++ b/main.go @@ -50,7 +50,7 @@ func _main() error { createCmd.Flags().StringP("group", "g", "", "Runner group to add the runner to, defaults to 'Default'") createCmd.Flags().BoolP("replace", "r", false, "Replace any existing runner with the same name") createCmd.Flags().BoolP("skip-download", "s", false, "Skip downloading the runner binary, because you already have one extracted in the current directory") - createCmd.Flags().BoolP("windows-service", "w", false, "Install the runner as a Windows Service (Windows only, requires admin privileges, use service create on linux and MacOS)") + createCmd.Flags().BoolP("windows-service", "w", false, "Install the runner as a Windows Service (Windows only, requires admin privileges, use `gh runner service create` on linux and MacOS)") createCmd.Flags().String("windowslogonaccount", "", "The logon account to use for the service (Windows only)") createCmd.Flags().String("windowslogonpassword", "", "The logon password to use for the service (Windows only)") @@ -87,7 +87,7 @@ func _main() error { serviceCreateCmd := &cobra.Command{ Use: "create", - Short: "create a service (and start it) on this machine to keep the runner running", + Short: "create a service (and start it) on this machine to keep the runner running (linux and MacOS only)", RunE: func(cmd *cobra.Command, args []string) (err error) { createService(*name) return @@ -114,7 +114,7 @@ func _main() error { serviceRemoveCmd := &cobra.Command{ Use: "remove", - Short: "Remove the service configured on this machine, ", + Short: "Remove the service configured on this machine (On Windows, remove the runner to remove the service) ", RunE: func(cmd *cobra.Command, args []string) (err error) { removeService(*name) return diff --git a/serviceCommands.go b/serviceCommands.go index c2b7163..b58a3d0 100644 --- a/serviceCommands.go +++ b/serviceCommands.go @@ -26,7 +26,6 @@ func runStart(name string) { func runStop(name string) { if runtime.GOOS != "windows" { - //kill the 3 created processes runnerprocs := fmt.Sprintf("%[1]s/run.sh|%[1]s/bin/Runner.Listener|%[1]s/run-helper.sh", name) //Find the pid of the runner @@ -46,7 +45,15 @@ func runStop(name string) { log.Fatal(err) } } else { - //TODO: Implement stop for windows + //TODO: Implement a better stop for windows + c1 := exec.Command("Stop-Process", "-Name", "Runner.Listener") + //kill the processes + c1.Stdout = os.Stdout + c1.Stderr = os.Stderr + err := c1.Run() + if err != nil { + log.Fatal(err) + } } } @@ -63,7 +70,7 @@ func createService(name string) { } else if runtime.GOOS == "linux" { runcmd = exec.Command("sudo", "./svc.sh", "install") } else if runtime.GOOS == "windows" { - log.Fatal("On windows, you must configure the service when creating the runner.") + log.Fatal("On Windows, you must configure the service when creating the runner. Remove the runner and re-create it with the --windows-service flag") } else { log.Fatal("Unsupported OS") } @@ -138,7 +145,7 @@ func removeService(name string) { } else if runtime.GOOS == "linux" { runcmd = exec.Command("sudo", "./svc.sh", "uninstall") } else if runtime.GOOS == "windows" { - runcmd = exec.Command("powershell", "Remove-Service", "actions.runner.*") + log.Fatal("On Windows, remove the runner to remove the service.") } else { log.Fatal("Unsupported OS") }