granitic: github.com/graniticio/granitic/facility/runtimectl Index | Files

package runtimectl

import "github.com/graniticio/granitic/facility/runtimectl"

Package runtimectl provides the RuntimeCtl facility which allows external runtime control of Granitic applications.

This facility is described in detail at https://granitic.io/ref/runtime-control Refer to the ctl package documentation for information on how to implement your own commands.

Enabling runtime control

Enabling the RuntimeCtl facility creates an HTTP server that allows instructions to be issued to any component in the IoC container which implements the ctl.Command interface from the grnc-ctl command line tool. See https://granitic.io/ref/runtime-control-built-in for documentation on Granitic's built-in commands.

The HTTP server that listens for commands is separate to the HTTP server created by the XMLWs and JSONWs facilities and runs on a different port. The listen port defaults to 9099 but can be changed with the following configuration:

{
  "RuntimeCtl": {
	"Server":{
	  "Port": 9099,
	  "Address": "127.0.0.1"
	}
  }
}

Note that by default the server only listens on the IPV4 localhost. To listen on all interfaces, change address to ""

Disabling individual commands

You can disable individual commands (either builtin commands or your own application commands) with configuration. For example:

{

  "RuntimeCtl": {
	"Manager":{
	  "Disabled": ["shutdown"]
	}
  }

}

Disables the shutdown command, preventing your application being stopped remotely.

Index

Package Files

builder.go builtin.go components.go help.go lifecycle.go shutdown.go start.go stop.go suspend.go

Constants

const (
    // All indicates that all components (framework and application) should be included
    All = iota
    // FrameworkOwned indicates that only components owned by Granitic should be included
    FrameworkOwned
    // ApplicationOwned indicates that only components owned by the application should be included
    ApplicationOwned
)
const (
    // Server is the component name that will be used for the runtime control server
    Server = instance.FrameworkPrefix + "CtlServer"
)

func Enabled Uses

func Enabled(ca *config.Accessor) bool

Enabled checks to see if the RuntimeCtl facility is enabled in configuration.

func OperateOnFramework Uses

func OperateOnFramework(args map[string]string) (bool, error)

OperateOnFramework returns true if framework components should be included in whatever command is being invoked.

type FacilityBuilder Uses

type FacilityBuilder struct {
}

FacilityBuilder creates and configures the RuntimeCtl facility.

func (*FacilityBuilder) BuildAndRegister Uses

func (fb *FacilityBuilder) BuildAndRegister(lm *logging.ComponentLoggerManager, ca *config.Accessor, cc *ioc.ComponentContainer) error

BuildAndRegister creates new instances of the structs that make up the RuntimeCtl facility, configures them and adds them to the IOC container.

func (*FacilityBuilder) DependsOnFacilities Uses

func (fb *FacilityBuilder) DependsOnFacilities() []string

DependsOnFacilities returns the list of other facilities that must be running in order to use RuntimeCtl (none)

func (*FacilityBuilder) FacilityName Uses

func (fb *FacilityBuilder) FacilityName() string

FacilityName returns the canonical name of this facility (RuntimeCtl)

Package runtimectl imports 18 packages (graph). Updated 2020-05-30. Refresh now. Tools for package owners.