cmd

package
v0.0.0-...-d2b7790 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StartCommand = &cli.Command{
	Name:  "start",
	Usage: "start program with rogue-finder",
	Flags: []cli.Flag{
		&cli.BoolFlag{Name: "daemon", Value: false, Usage: "run rogue-finder in background mode"},
	},
	Action: func(ctx *cli.Context) error {
		defer func() {
			for _, err := range self.RunClearFuncs() {
				log.Printf("[E] Run clear funcs: %v", err)
			}
		}()

		if isDaemon := ctx.Bool("daemon"); isDaemon {
			if err := procutil.RunInBackground(runutil.ExecutableName, []string{"start"}, nil, nil); err != nil {
				log.Fatalf("[F] Run app in background failure, nest error: %v", err)
			}
			return nil
		}

		for _, dir := range []string{
			filepath.Join(runutil.ExecutableDir, "../log"),
			filepath.Join(runutil.ExecutableDir, "../var/run"),
		} {
			if err := fs.CreateDir(dir); err != nil {
				log.Fatalf("[F] Create runtime dir failure, nest error: %v", err)
			}
		}
		fs.StderrFilePath = filepath.Join(runutil.ExecutableDir, "../log/panic.log")
		fs.RewriteStderrFile()

		if err := setupConfig(); err != nil {
			return err
		}

		setupGlobalVars()

		if err := setupEnv(); err != nil {
			return err
		}
		if err := runServer(); err != nil {
			return err
		}
		procutil.WaitForSigterm()
		return nil
	},
}
View Source
var StopCommand = &cli.Command{
	Name:  "stop",
	Usage: "stop program with rogue-finder",
	Action: func(ctx *cli.Context) error {
		var pidFile = filepath.Join(runutil.ExecutableDir, "../var/run/rogue-finder.pid")
		process, err := procutil.FindWithPidFile(pidFile)
		if err != nil {
			return err
		} else {
			if err := process.Signal(syscall.SIGQUIT); err != nil {
				return nil
			}
		}
		return nil
	},
}
View Source
var VersionCommand = &cli.Command{
	Name:  "version",
	Usage: "version about rogue-finder",
	Action: func(ctx *cli.Context) error {
		fmt.Println(buildinfo.GetVersion())
		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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