service_manager

package
v0.0.0-...-89602ce Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2020 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

  • Copyright 2020 The Magma Authors. *
  • This source code is licensed under the BSD-style license found in the
  • LICENSE file in the root directory of this source tree. *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

package service_manager defines and implements API for service management

package service_manager defines and implements API for service management

  • Copyright 2020 The Magma Authors. *
  • This source code is licensed under the BSD-style license found in the
  • LICENSE file in the root directory of this source tree. *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

package service_manager defines and implements API for service management

  • Copyright 2020 The Magma Authors. *
  • This source code is licensed under the BSD-style license found in the
  • LICENSE file in the root directory of this source tree. *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

package service_manager defines and implements API for service management

  • Copyright 2020 The Magma Authors. *
  • This source code is licensed under the BSD-style license found in the
  • LICENSE file in the root directory of this source tree. *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

package service_manager defines and implements API for service management

  • Copyright 2020 The Magma Authors. *
  • This source code is licensed under the BSD-style license found in the
  • LICENSE file in the root directory of this source tree. *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

package service_manager defines and implements API for service management

Index

Constants

View Source
const DefaultInitdLogTailCmd = "tail -f /var/log/syslog"

DefaultInitdLogTailCmd logs tail command if none is specified

View Source
const MaxDockerContainersToTail = 32

Variables

This section is empty.

Functions

func StartCmdWithStderrStdoutTailer

func StartCmdWithStderrStdoutTailer(cmd *exec.Cmd) (chan string, *os.Process, error)

StartCmdWithStderrStdoutTailer starts given command and waits for its completion, StartCmdWithStderrStdoutTailer creates the chan where all stderr & stdout strings are sent The chan will be closed when both stdout & stderr streams are closed or have errors To terminate the running command - use Process.Kill()

Types

type DockerController

type DockerController struct{}

DockerController - docker based controller implementation

func (DockerController) GetState

func (dc DockerController) GetState(service string) (ServiceState, error)

GetState returns the given service state or error if unsuccessful

func (DockerController) Name

func (DockerController) Name() string

Name returns Docker controller type name

func (DockerController) Restart

func (dc DockerController) Restart(service string) error

Restart restarts service and returns error if unsuccessful

func (DockerController) Start

func (dc DockerController) Start(service string) error

Start starts service and returns error if unsuccessful

func (DockerController) Stop

func (dc DockerController) Stop(service string) error

Stop stops service and returns error if unsuccessful

func (DockerController) TailLogs

func (dc DockerController) TailLogs(service string) (chan string, *os.Process, error)

TailLogs executes command to start tailing service logs and returns string chan to receive log strings closing the chan will terminate tailing

type InitdController

type InitdController struct {
	TailLogsCmd string
}

InitdController - initd based controller implementation

func (InitdController) CmdName

func (InitdController) CmdName(service string) string

CmdName returns the base name of the start/stop/status command

func (InitdController) GetState

func (c InitdController) GetState(service string) (ServiceState, error)

GetState returns the given service state or error if unsuccessful

func (InitdController) Name

func (InitdController) Name() string

Name returns runit controller type name

func (InitdController) Restart

func (c InitdController) Restart(service string) error

Restart restarts service and returns error if unsuccessful

func (InitdController) Start

func (c InitdController) Start(service string) error

Start starts service and returns error if unsuccessful

func (InitdController) Stop

func (c InitdController) Stop(service string) error

Stop stops service and returns error if unsuccessful

func (InitdController) TailLogs

func (c InitdController) TailLogs(service string) (chan string, *os.Process, error)

TailLogs executes command to start tailing service logs and returns string chan to receive log strings closing the chan will terminate tailing

type RunitController

type RunitController struct{}

RunitController - runit based controller implementation

func (RunitController) CmdName

func (RunitController) CmdName() string

func (RunitController) GetState

func (c RunitController) GetState(service string) (ServiceState, error)

GetState returns the given service state or error if unsuccessful

func (RunitController) Name

func (RunitController) Name() string

Name returns runit controller type name

func (RunitController) Restart

func (c RunitController) Restart(service string) error

Restart restarts service and returns error if unsuccessful

func (RunitController) ServiceName

func (RunitController) ServiceName(service string) string

func (RunitController) Start

func (c RunitController) Start(service string) error

Start starts service and returns error if unsuccessful

func (RunitController) Stop

func (c RunitController) Stop(service string) error

Stop stops service and returns error if unsuccessful

func (RunitController) TailLogs

func (c RunitController) TailLogs(service string) (chan string, *os.Process, error)

TailLogs executes command to start tailing service logs and returns string chan to receive log strings closing the chan will terminate tailing

type ServiceController

type ServiceController interface {
	// Name returns the type of the init system used by the GW, it should match magmad.yml "init_system" value
	Name() string
	// Start starts service and returns error if unsuccessful
	Start(service string) error
	// Stop stops service and returns error if unsuccessful
	Stop(service string) error
	// Restart restarts service and returns error if unsuccessful
	Restart(service string) error
	// GetState returns the given service state or error if unsuccessful
	GetState(service string) (ServiceState, error)

	// TailLogs executes command to start tailing service logs and returns string chan to receive log strings
	// closing the chan will terminate tailing
	TailLogs(service string) (chan string, *os.Process, error)
}

ServiceController defines service controller API for service manager providers

func Get

func Get() ServiceController

Get returns Service Controller for configured init system or the default controller if match cannot be found

type ServiceState

type ServiceState int
const (
	Active ServiceState
	Activating
	Deactivating
	Inactive
	Failed
	Unknown
	Error
)

type SystemdController

type SystemdController struct{}

SystemdController - systemd based controller implementation

func (SystemdController) CmdName

func (SystemdController) CmdName() string

func (SystemdController) GetState

func (c SystemdController) GetState(service string) (ServiceState, error)

GetState returns the given service state or error if unsuccessful

func (SystemdController) Name

func (SystemdController) Name() string

Name returns systemd controller type name

func (SystemdController) Restart

func (c SystemdController) Restart(service string) error

Restart restarts service and returns error if unsuccessful

func (SystemdController) ServiceName

func (SystemdController) ServiceName(service string) string

func (SystemdController) Start

func (c SystemdController) Start(service string) error

Start starts service and returns error if unsuccessful

func (SystemdController) Stop

func (c SystemdController) Stop(service string) error

Stop stops service and returns error if unsuccessful

func (SystemdController) TailLogs

func (c SystemdController) TailLogs(service string) (chan string, *os.Process, error)

TailLogs executes command to start tailing service logs and returns string chan to receive log strings closing the chan will terminate tailing

Jump to

Keyboard shortcuts

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