Skip to content

Commit

Permalink
Some additional windows support
Browse files Browse the repository at this point in the history
  • Loading branch information
Dedac committed May 22, 2023
1 parent 9926a64 commit 5e9c0a7
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 16 deletions.
35 changes: 26 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,35 @@ You can start and stop the runner as a process, or use 'service' to install it a

```
Usage:
runner create [<options>] [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 [<options>] [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)
```
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)")

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
15 changes: 11 additions & 4 deletions serviceCommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
}
}

Expand All @@ -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")
}
Expand Down Expand Up @@ -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")
}
Expand Down

0 comments on commit 5e9c0a7

Please sign in to comment.