daemon

package
v0.2.11 Latest Latest
Warning

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

Go to latest
Published: May 25, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DaemonServerCommands = &cmdr.Command{
		BaseOpt: cmdr.BaseOpt{

			Short:       "s",
			Full:        "server",
			Aliases:     []string{"serve", "svr", "daemon"},
			Description: "server ops: for linux daemon.",
		},
		SubCommands: []*cmdr.Command{
			{
				BaseOpt: cmdr.BaseOpt{
					Short:       "s",
					Full:        "start",
					Aliases:     []string{"run", "startup"},
					Description: "startup this system service/daemon.",
					Action:      daemonStart,
					Flags: []*cmdr.Flag{
						{
							BaseOpt: cmdr.BaseOpt{
								Short:       "f",
								Full:        "foreground",
								Aliases:     []string{"fg"},
								Description: "run on foreground, NOT daemonized.",
							},
							DefaultValue: false,
						},
					},
				},
			},
			{
				BaseOpt: cmdr.BaseOpt{
					Short:       "t",
					Full:        "stop",
					Aliases:     []string{"stp", "halt", "pause"},
					Description: "stop this system service/daemon.",
					Action:      daemonStop,
				},
			},
			{
				BaseOpt: cmdr.BaseOpt{
					Short:       "re",
					Full:        "restart",
					Aliases:     []string{"reload"},
					Description: "restart this system service/daemon.",
					Action:      daemonRestart,
				},
			},
			{
				BaseOpt: cmdr.BaseOpt{
					Full:        "status",
					Aliases:     []string{"st"},
					Description: "display its running status as a system service/daemon.",
					Action:      daemonStatus,
				},
			},
			{
				BaseOpt: cmdr.BaseOpt{
					Short:       "i",
					Full:        "install",
					Aliases:     []string{"setup"},
					Description: "install as a system service/daemon.",
					Action:      daemonInstall,
					Flags: []*cmdr.Flag{
						{
							BaseOpt: cmdr.BaseOpt{
								Short:       "s",
								Full:        "systemd",
								Aliases:     []string{"sys"},
								Description: "install as a systemd service.",
							},
							DefaultValue: true,
						},
					},
				},
			},
			{
				BaseOpt: cmdr.BaseOpt{
					Short:       "u",
					Full:        "uninstall",
					Aliases:     []string{"remove"},
					Description: "remove from a system service/daemon.",
					Action:      daemonUninstall,
				},
			},
		},
	}
)
View Source
var ErrNoRoot = errors.New("MUST have administrator privileges")

Functions

func Enable

func Enable(daemonImpl_ Daemon)

func Exec

func Exec(cmd string, args ...string) error

Exec executes a command setting both standard input, output and error.

func ExecSudo

func ExecSudo(cmd string, args ...string) error

ExecSudo executes a command under "sudo".

Types

type Context

type Context struct {
	daemon.Context
}

type Daemon

type Daemon interface {
	OnRun(cmd *cmdr.Command, args []string, stopCh, doneCh chan struct{}) (err error)
	OnStop(cmd *cmdr.Command, args []string) (err error)
	OnReload()
	OnStatus(cxt *Context, cmd *cmdr.Command, p *os.Process) (err error)
	OnInstall(cxt *Context, cmd *cmdr.Command, args []string) (err error)
	OnUninstall(cxt *Context, cmd *cmdr.Command, args []string) (err error)
}

Jump to

Keyboard shortcuts

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