Documentation ¶
Overview ¶
Package runner exposes the APIs used by God for deploy and manage services in the Go ecosystem.
Index ¶
- type Conf
- type MessageStatus
- type Runner
- type Service
- func (s *Service) AuthPrivateRepo() error
- func (s *Service) CheckGo() error
- func (s *Service) CheckLingering() error
- func (s *Service) CheckSystemd() error
- func (s *Service) CheckWorkingDir(createWorkingDirectory bool) error
- func (service *Service) CopyFile(path, workingDirectory string) error
- func (s *Service) CopyFiles() error
- func (service *Service) CopyUnitServiceFile() error
- func (s *Service) CreateServiceFile() error
- func (service *Service) DeleteDirIfEmpty(dirPath string) error
- func (s *Service) DeleteExecutable() error
- func (service *Service) DeleteFile(path, workingDirectory string) error
- func (s *Service) DeleteFiles(removeWorkingDirectory bool) error
- func (s *Service) DeleteServiceFile() error
- func (s *Service) DisableService() error
- func (s *Service) EnableService() error
- func (service *Service) Exec(cmd string) (string, error)
- func (service *Service) GenerateServiceFile(buf io.Writer)
- func (s *Service) Install(createWorkingDirectory bool) error
- func (s *Service) InstallExecutable() error
- func (service *Service) ParseCommand(cmd string) string
- func (service *Service) PrintExec(cmd, errorMessage string) error
- func (s *Service) ReloadDaemon() error
- func (s *Service) ResetFailedServices() error
- func (s *Service) RestartService() error
- func (s *Service) ShowServiceFile()
- func (s *Service) StartService() error
- func (s *Service) StatusService() error
- func (s *Service) StopService() error
- func (s *Service) Uninstall(removeWorkingDirectory bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conf ¶
type Conf struct { User string `yaml:"user"` Host string `yaml:"host"` Port string `yaml:"port"` PrivateKeyPath string `yaml:"private_key_path"` GoExecPath string `yaml:"go_exec_path"` GoBinDirectory string `yaml:"go_bin_directory"` GoInstall string `yaml:"go_install"` GoPrivate string `yaml:"go_private"` NetrcMachine string `yaml:"netrc_machine"` NetrcLogin string `yaml:"netrc_login"` NetrcPassword string `yaml:"netrc_password"` SystemdPath string `yaml:"systemd_path"` SystemdServicesDirectory string `yaml:"systemd_services_directory"` SystemdLingerDirectory string `yaml:"systemd_linger_directory"` ExecStart string `yaml:"exec_start"` WorkingDirectory string `yaml:"working_directory"` Environment string `yaml:"environment"` LogPath string `yaml:"log_path"` RunAfterService string `yaml:"run_after_service"` StartLimitBurst int `yaml:"start_limit_burst"` StartLimitIntervalSec int `yaml:"start_limit_interval_sec"` RestartSec int `yaml:"restart_sec"` CopyFiles []string `yaml:"copy_files"` Ignore bool `yaml:"ignore"` }
Conf holds a service configuration.
type MessageStatus ¶
type MessageStatus uint8
Types of messages. Types are normal, success and error.
const ( // Normal message (uncolored) MessageNormal MessageStatus = 1 << iota // 1 << 0 which is 00000001 // Success message (green) MessageSuccess // 1 << 1 which is 00000010 // Error message (red) MessageError // 1 << 2 which is 00000100 // Warning message (yellow) MessageWarning // 1 << 3 which is 00001000 )
type Runner ¶
type Runner struct { QuietMode bool // contains filtered or unexported fields }
func MakeRunner ¶
MakeRunner loads the configuration from confFilePath and returns an initialized Runner.
func (*Runner) GetServiceNames ¶
GetServiceNames returns a slice with all not ignored services found in the configuration file.
func (*Runner) MakeService ¶
MakeService makes a new Service using the configuration under serviceName key in the configuration file.
func (*Runner) SendMessage ¶
func (runner *Runner) SendMessage(serviceName, text string, status MessageStatus)
SendMessage writes a message in the runner channel that can be captured and printed by the go routine started with StartPrintOutput.
func (*Runner) StartPrintOutput ¶
StartPrintOutput starts a go routine that read messages from runner channel and prints them.
func (*Runner) StopPrintOutput ¶
func (runner *Runner) StopPrintOutput()
StopPrintOutput stop the go routine started with StartPrintOutput.
type Service ¶
type Service struct { // The service name (key in the configuration YAML file) Name string // Configuration under the key in the configuration YAML file Conf *Conf // contains filtered or unexported fields }
Service represents a service that will be installed and launched on the remote machine.
func (*Service) AuthPrivateRepo ¶
func (*Service) CheckLingering ¶
func (*Service) CheckSystemd ¶
func (*Service) CheckWorkingDir ¶ added in v0.1.0
func (*Service) CopyFile ¶
CopyFile copies the local file on the remote host to the remote workingDirectory. If the local file is a directory, create the directory on the remote host and recursively copy all files inside.
func (*Service) CopyUnitServiceFile ¶ added in v0.1.0
CopyUnitServiceFile copies the systemd unit service file on the remote host.
func (*Service) CreateServiceFile ¶
func (*Service) DeleteDirIfEmpty ¶ added in v0.1.0
DeleteDirIfEmpty deletes remote directory only if empty.
func (*Service) DeleteExecutable ¶
func (*Service) DeleteFile ¶ added in v0.1.0
DeleteFile deletes the file on the remote host relative to the remote workingDirectory.
func (*Service) DeleteFiles ¶ added in v0.1.0
func (*Service) DeleteServiceFile ¶
func (*Service) DisableService ¶
func (*Service) EnableService ¶
func (*Service) GenerateServiceFile ¶
GenerateServiceFile generates the systemd unit service file using the service configuration.
func (*Service) InstallExecutable ¶
func (*Service) ParseCommand ¶
ParseCommand parses the cmd string replacing the variables with those present in the configuration.
func (*Service) PrintExec ¶
PrintExec runs cmd on the remote host and sends the output on the runner channel.
func (*Service) ReloadDaemon ¶
func (*Service) ResetFailedServices ¶
func (*Service) RestartService ¶
func (*Service) ShowServiceFile ¶
func (s *Service) ShowServiceFile()