util

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstallArchive

func InstallArchive(ctx context.Context, node string, rawURL string, dest string) error

InstallArchive runs on node, downloads the URL and extracts the archive to the dest diretory. Supports zip, and tarball.

func IsDaemonRunning

func IsDaemonRunning(ctx context.Context, node string, cmd string, pidFile string) bool

IsDaemonRunning runs on node and returns whether the daemon is still running or not.

func IsDir

func IsDir(ctx context.Context, node string, path string) bool

IsDir runs on node and checks path is directory or not.

func IsFileExist

func IsFileExist(ctx context.Context, node string, name string) bool

IsFileExist runs on node and returns true if the file exists.

func IsProcessExist

func IsProcessExist(ctx context.Context, node string, pid int) bool

IsProcessExist runs on node and returns true if the porcess still exists.

func KillDaemon

func KillDaemon(ctx context.Context, node cluster.Node, cmd string, pidFile string) error

KillDaemon runs on node and kills the daemon process.

func MatchInArray

func MatchInArray(arr []string, value string) bool

MatchInArray returns true if the given string value is in the array.

func Mkdir

func Mkdir(ctx context.Context, node string, dir string) error

Mkdir runs on node and makes a directory

func ReadDir

func ReadDir(ctx context.Context, node string, dir string) ([]string, error)

ReadDir runs on node and lists the files of dir.

func RemoveDir

func RemoveDir(ctx context.Context, node string, dir string) error

RemoveDir runs on node and removes the diretory

func StartDaemon

func StartDaemon(ctx context.Context, node string, opts DaemonOptions, cmd string, cmdArgs ...string) error

StartDaemon runs on node and starts a daemon process with options

func StopDaemon

func StopDaemon(ctx context.Context, node string, cmd string, pidFile string) error

StopDaemon runs on node and stops the daemon process.

func Wget

func Wget(ctx context.Context, node string, rawURL string, dest string) (string, error)

Wget runs on node, downloads a string URL to the dest directory and returns the file path. SKips if the file already exists.

func WriteFile

func WriteFile(ctx context.Context, node string, file string, data string) error

WriteFile runs on node and writes data to file

Types

type BlockRunner

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

BlockRunner provides a simple way to run tasks, block until all the tasks are finished.

func (*BlockRunner) Init

func (r *BlockRunner) Init(n int)

Init initializes how many tasks we want to run synchronously.

func (*BlockRunner) Run

func (r *BlockRunner) Run(f func())

Run runs the task in different goroutines and block until all the tasks are finished.

type DaemonOptions

type DaemonOptions struct {
	ChDir   string
	PidFile string
	NoClose bool
}

DaemonOptions is the options to start a command in daemon mode.

func NewDaemonOptions

func NewDaemonOptions(chDir string, pidFile string) DaemonOptions

NewDaemonOptions returns a default daemon options.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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