services

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package services implements the 'services' command.

Manage background services

Manage background services for installed formulas. Services are registered with the platform init system (launchd) so they persist across reboots.

Index

Constants

This section is empty.

Variables

View Source
var Command = &cobra.Command{
	Use:   "services <subcommand> [arguments]",
	Short: "Manage background services",
	Long: `Manage background services for installed formulas. Services are
registered with the platform init system (launchd) so they persist across reboots.

Subcommands:
  list, ls              List all managed services and their status
  start <formula>       Write a service definition and start it
  stop <formula>        Stop the service and remove its definition
  restart <formula>     Stop then start the service
  run <formula>         Run the service command in the foreground
  info <formula>        Show service configuration and status

The service definition comes from the formula's "service" field.
The run command supports {prefix}, {opt}, and {cellar} placeholders
that are expanded to the grew directory paths.

On macOS, services are managed via launchctl (~/Library/LaunchAgents).

Examples:
  grew services list
  grew services start postgresql
  grew services stop redis
  grew services restart postgresql
  grew services run postgresql
  grew services info postgresql`,
	RunE: func(c *cobra.Command, args []string) error {
		slog.Debug("starting services command execution")
		if len(args) == 0 {
			return c.Help()
		}

		sub := args[0]
		rest := args[1:]

		switch sub {
		case "list", "ls":
			return servicesList(rest)
		case "start":
			return servicesStart(rest)
		case "stop":
			return servicesStop(rest)
		case "restart":
			return servicesRestart(rest)
		case "run":
			return servicesRun(rest)
		case "info":
			return servicesInfo(rest)
		default:
			return fmt.Errorf("unknown services subcommand: %s\nRun 'grew help services' for usage", sub)
		}
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL