svc

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const InternalRegistryHost = "catchit.dev"

InternalRegistryHost is the domain name for the internal registry.

Variables

View Source
var ErrDockerNotFound = fmt.Errorf("docker not found")
View Source
var ErrDockerStatusUnknown = fmt.Errorf("unknown docker status")
View Source
var (
	ErrNotInstalled = errors.New("the service is not installed")
)

Functions

func DockerCmd

func DockerCmd() (string, error)

DockerCmd returns the path to the docker binary.

Types

type DockerComposeService

type DockerComposeService struct {
	Name string

	DataDir string
	NewCmd  func(name string, arg ...string) *exec.Cmd
	// contains filtered or unexported fields
}

func NewDockerComposeService

func NewDockerComposeService(db *db.Store, cfg db.ServiceView, dataDir, runDir string) (*DockerComposeService, error)

NewDockerComposeService creates a new docker compose service from a config.

func (*DockerComposeService) AnyRunning

func (s *DockerComposeService) AnyRunning() (bool, error)

AnyRunning returns true if any compose container is currently running.

func (*DockerComposeService) Down

func (s *DockerComposeService) Down() error

func (*DockerComposeService) Exists

func (s *DockerComposeService) Exists() (bool, error)

func (*DockerComposeService) Install

func (s *DockerComposeService) Install() error

func (*DockerComposeService) InstallWithPull

func (s *DockerComposeService) InstallWithPull(pull bool) error

func (*DockerComposeService) Logs

func (s *DockerComposeService) Logs(opts *LogOptions) error

func (*DockerComposeService) PrePullIfRunning

func (s *DockerComposeService) PrePullIfRunning() error

PrePullIfRunning pulls images while containers are still running to reduce downtime.

func (*DockerComposeService) Pull

func (s *DockerComposeService) Pull() error

Pull pulls the docker images used by this compose service without restarting it.

func (*DockerComposeService) Remove

func (s *DockerComposeService) Remove() error

func (*DockerComposeService) Restart

func (s *DockerComposeService) Restart() error

func (*DockerComposeService) Start

func (s *DockerComposeService) Start() error

func (*DockerComposeService) Status

func (s *DockerComposeService) Status() (Status, error)

func (*DockerComposeService) Statuses

func (*DockerComposeService) Stop

func (s *DockerComposeService) Stop() error

func (*DockerComposeService) Up

func (s *DockerComposeService) Up() error

func (*DockerComposeService) UpWithPull

func (s *DockerComposeService) UpWithPull(pull bool) error

func (*DockerComposeService) Update

func (s *DockerComposeService) Update() error

Update pulls images (prefetching if running) and recreates containers.

type DockerComposeStatus

type DockerComposeStatus map[string]Status

type LogOptions

type LogOptions struct {
	Follow bool
	Lines  int
}

type Status

type Status string
const (
	StatusRunning Status = "Running"
	StatusStopped Status = "Stopped"
	StatusUnknown Status = "Unknown"
)

type SystemdService

type SystemdService struct {
	// contains filtered or unexported fields
}

func NewSystemdService

func NewSystemdService(db *db.Store, cfg db.ServiceView, runDir string) (*SystemdService, error)

NewSystemdService creates a new systemd service from a SystemdConfigView.

func (*SystemdService) Disable

func (s *SystemdService) Disable() error

func (*SystemdService) Enable

func (s *SystemdService) Enable() error

func (*SystemdService) Install

func (s *SystemdService) Install() error

func (*SystemdService) Name

func (s *SystemdService) Name() string

func (*SystemdService) Restart

func (s *SystemdService) Restart() error

func (*SystemdService) Start

func (s *SystemdService) Start() error

func (*SystemdService) Status

func (s *SystemdService) Status() (Status, error)

func (*SystemdService) Stop

func (s *SystemdService) Stop() error

func (*SystemdService) Uninstall

func (s *SystemdService) Uninstall() error

type SystemdUnit

type SystemdUnit struct {
	Name string // Required name of the service. No spaces suggested.

	// User is the user to run the service as.
	User string

	// Executable is the path to the executable to run or the command to run.
	Executable string

	// Arguments are the arguments to pass to the service.
	Arguments []string

	// OneShot, when true, will run the service as a oneshot service.
	OneShot bool

	// StopCmd is the command to run to stop the service.
	StopCmd string

	// Timer, when set, will defer running of the service to a separate timer
	// unit. This is used for `cron` like functionality. If Timer is nil, the
	// service is configured normally.
	Timer *TimerConfig

	// EnvFile is the path to an environment file.
	EnvFile string

	// WorkingDirectory is the working directory for the service.
	WorkingDirectory string

	// NetNS is the network namespace the service is in.
	// If empty, the service is on the host network.
	NetNS string

	// Requires is a list of services that this service requires to run.
	// For multiple services, separate with spaces.
	Requires string

	// ResolvConf is the path to the resolv.conf file to use.
	ResolvConf string
}

func (*SystemdUnit) WriteOutUnitFiles

func (u *SystemdUnit) WriteOutUnitFiles(root string) (map[db.ArtifactName]string, error)

type TimerConfig

type TimerConfig struct {
	Description string `json:",omitempty"` // Description of the timer.
	OnCalendar  string // Run on a calendar event.
	Persistent  bool   // Ensures missed timer events run after system resumes from downtime.
}

TimerConfig provides the setup for a Timer. The OnCalendar field is required.

Jump to

Keyboard shortcuts

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