services

package
v0.0.0-...-012c905 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2017 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OK_SIGNAL   = "ok"
	STOP_SIGNAL = "stop"
	KILL_SIGNAL = "kill"
)
View Source
const CANT_FIND_SERVICE = "Can't find service"
View Source
const SERVICES_JSON = "services.json"

Variables

This section is empty.

Functions

func CallMakeDepGen

func CallMakeDepGen(service Service) error

func CallStepByStep

func CallStepByStep(svc Service, states ...Step) error

func HandleAllServicesNames

func HandleAllServicesNames(_ []byte) interface{}

func HandleGetEnv

func HandleGetEnv(input []byte) interface{}

func HandleKillServices

func HandleKillServices(input []byte) interface{}

func HandleLoadAllServices

func HandleLoadAllServices(_ []byte) interface{}

func HandleLoadServices

func HandleLoadServices(input []byte) interface{}

func HandleReloadEnv

func HandleReloadEnv(_ []byte) interface{}

func HandleRestartServices

func HandleRestartServices(input []byte) interface{}

func HandleServicesInfo

func HandleServicesInfo(input []byte) interface{}

func HandleStartServices

func HandleStartServices(input []byte) interface{}

func HandleStopServices

func HandleStopServices(input []byte) interface{}

func NewHTTPWrapper

func NewHTTPWrapper(wrapped LogicHandler) http.HandlerFunc

func ServeAllServicesNames

func ServeAllServicesNames() <-chan []string

func ServeGetEnv

func ServeGetEnv(allFlag bool) <-chan []string

func ServeKillServices

func ServeKillServices(svcNames ...string) <-chan error

func ServeLoadAllServices

func ServeLoadAllServices() <-chan error

func ServeLoadServices

func ServeLoadServices(svcNames ...string) <-chan error

func ServeReloadEnv

func ServeReloadEnv() <-chan error

func ServeRestartServices

func ServeRestartServices(svcNames ...string) <-chan error

func ServeServicesInfo

func ServeServicesInfo(allFlag bool) <-chan []ServiceInfo

func ServeStartServices

func ServeStartServices(svcNames ...string) <-chan error

func ServeStopServices

func ServeStopServices(svcNames ...string) <-chan error

func StopServer

func StopServer(w http.ResponseWriter, _ *http.Request)

func SwitchVersion

func SwitchVersion(service Service) error

Types

type Action

type Action func(Service) error

type LogicHandler

type LogicHandler func([]byte) interface{}

type Manager

type Manager interface {
	RegisterService(config *ServiceConfig) error // Add new service to configuration.
	Start(svcNames ...string) error              // Start services with specified names.
	Stop(svcNames ...string) error               // Normal and safely stop services with specified names.
	Restart(svcNames ...string) error            // Restart services with specified names.
	Kill(svcNames ...string) error               // Fast and rude stop services with specified names.
	Info(allFlag bool) []ServiceInfo             // Information about configured services.
	AllServicesNames() []string                  // List of all services in configuration.
}

type Service

type Service interface {
	Name() string       // Name of service. By this name manager provide operations.
	Prepare() error     // All what should be done first
	Build() error       // All actions that should happened before run.
	Start() error       // Start service.
	Stop() error        // Normal stop service.
	Kill() error        // Fast stop service.
	Info() *ServiceInfo // General information about current service for `ps` command.
	Sync() error        // Sync service with command line. Should be called after Stop/Kill or before Start to prevent desync.
	IsRunning() bool    // Check, is service is idling or working.
}

type ServiceConfig

type ServiceConfig struct {
	Name    string   `json:"name"`    // Name of service
	Target  string   `json:"target"`  // Path to Makefile inside Dir/Name/
	Args    []string `json:"args"`    // Command line arguments for service
	Dir     string   `json:"dir"`     // Full path to directory with service
	Version string   `json:"version"` // Git tag, which can be represented as semantic versioning http://semver.org/
}

type ServiceInfo

type ServiceInfo struct {
	Name        string    // Имя сервиса
	Status      string    // Состояние сервиса
	StartupTime time.Time // Timestamp запуска
	Args        []string  // Параметры командной строки, передаваемой при запуске сервиса
	Dir         string    // Папка, в которой находится сервис
	Target      string    // Makefile с шагами install, gen, dep которые вызываются при сборке и смене версий
	Version     string    // Запускаемая версия версия, соответствующая http://semver.org/
}

type ServiceRepository

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

func NewRepository

func NewRepository() *ServiceRepository

func (*ServiceRepository) GetService

func (f *ServiceRepository) GetService(svcName string) (Service, error)

func (*ServiceRepository) Names

func (f *ServiceRepository) Names() []string

func (*ServiceRepository) RegisterService

func (f *ServiceRepository) RegisterService(config *ServiceConfig) error

type Step

type Step struct {
	Name string
	Do   Action
}

Jump to

Keyboard shortcuts

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