mageutil

package
v0.0.15-alpha.10 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColorBlue   = "\033[0;34m"
	ColorGreen  = "\033[0;32m"
	ColorRed    = "\033[0;31m"
	ColorYellow = "\033[33m"
	ColorReset  = "\033[0m"
)
View Source
const (
	MountConfigFilePath = "CONFIG_PATH"
	DeploymentType      = "DEPLOYMENT_TYPE"
	KUBERNETES          = "kubernetes"

	// Directory name constants
	ConfigDir    = "config"
	OutputDir    = "_output"
	SrcDir       = "cmd"
	ToolsDir     = "tools"
	TmpDir       = "tmp"
	LogsDir      = "logs"
	BinDir       = "bin"
	PlatformsDir = "platforms"
)

Path constants

View Source
const (
	StartConfigFile = "start-config.yml"
)

Variables

View Source
var (
	MaxFileDescriptors int
)

Functions

func BatchKillExistBinaries added in v0.0.8

func BatchKillExistBinaries(binaryPaths []string)

func Build added in v0.0.13

func Build(binaries []string, pathOpts *PathOptions)

func CheckAndReportBinariesStatus

func CheckAndReportBinariesStatus()

CheckAndReportBinariesStatus checks the running status of all binary files and reports it.

func CheckBinariesRunning

func CheckBinariesRunning() error

CheckBinariesRunning checks if all binary files are running as expected and returns any errors encountered.

func CheckBinariesStop

func CheckBinariesStop() error

CheckBinariesStop checks if all binary files have stopped and returns an error if there are any binaries still running.

func CheckProcessInMap added in v0.0.9

func CheckProcessInMap(processMap map[string]int, processPath string) bool

func CheckProcessNames

func CheckProcessNames(processPath string, expectedCount int, processMap map[string]int) error

CheckProcessNames checks if the number of processes running that match the specified path equals the expected count.

func CompileForPlatform

func CompileForPlatform(cgoEnabled string, platform string, compileBinaries []string)

CompileForPlatform Main compile function

func DetectPlatform

func DetectPlatform() string

DetectPlatform detects the operating system and architecture.

func FetchProcesses added in v0.0.9

func FetchProcesses() (map[string]int, error)

FetchProcesses returns a map of executable paths to their running count.

func FindPIDsByBinaryPath

func FindPIDsByBinaryPath() (map[string][]int, error)

FindPIDsByBinaryPath returns a map of executable paths to slices of PIDs.

func GetBinFullPath

func GetBinFullPath(binName string) string

Compatibility: maintain original global functions

func GetBinToolsFullPath added in v0.0.16

func GetBinToolsFullPath(toolName string) string

func InitForSSC

func InitForSSC()

func KillExistBinaries

func KillExistBinaries()

KillExistBinaries iterates over all binary files and kills their corresponding processes.

func KillExistBinary

func KillExistBinary(binaryPath string)

KillExistBinary kills all processes matching the given binary file path.

func OsArch

func OsArch() string

func PrintBinaryPorts

func PrintBinaryPorts(binaryPath string, pidMap map[string][]int)

func PrintBlue

func PrintBlue(message string)

Colored print with timestamp

func PrintBlueTwoLine

func PrintBlueTwoLine(message string)

Two-line format (timestamp on separate line)

func PrintGreen

func PrintGreen(message string)

func PrintGreenNoTimeStamp

func PrintGreenNoTimeStamp(message string)

func PrintGreenToStdOut

func PrintGreenToStdOut(a ...any) (n int, err error)

func PrintGreenTwoLine

func PrintGreenTwoLine(message string)

func PrintListenedPortsByBinaries

func PrintListenedPortsByBinaries() error

PrintListenedPortsByBinaries iterates over all binary files and prints the ports they are listening on.

func PrintRed

func PrintRed(message string)

func PrintRedNoTimeStamp

func PrintRedNoTimeStamp(message string)

Version without timestamp

func PrintRedToStdErr

func PrintRedToStdErr(a ...any) (n int, err error)

Output to specific streams

func PrintYellow added in v0.0.4

func PrintYellow(message string)

func Protocol added in v0.0.14

func Protocol() error

func RemoveOmitemptyFromFile added in v0.0.14

func RemoveOmitemptyFromFile(filePath string) error

func StartBinaries

func StartBinaries(specificBinaries ...string) error

StartBinaries Start all binary services or specified ones.

func StartTools

func StartTools(specificTools ...string) error

StartTools starts all tool binaries or specified ones.

func StartToolsAndServices

func StartToolsAndServices(binaries []string, pathOpts *PathOptions)

StartToolsAndServices starts the process for tools and services.

func StopAndCheckBinaries

func StopAndCheckBinaries()

StopAndCheckBinaries stops all binary processes and checks if they have all stopped.

func StopBinaries

func StopBinaries()

StopBinaries iterates over all binary files and terminates their corresponding processes.

func UpdateGlobalPaths added in v0.0.16

func UpdateGlobalPaths(opts *PathOptions) error

UpdateGlobalPaths updates the global Paths variable with new options

Types

type Config

type Config struct {
	ServiceBinaries    map[string]int `yaml:"serviceBinaries"`
	ToolBinaries       []string       `yaml:"toolBinaries"`
	MaxFileDescriptors int            `yaml:"maxFileDescriptors"`
}

type PathConfig added in v0.0.16

type PathConfig struct {
	Root               string
	Config             string
	K8sConfig          string
	Output             string
	OutputTools        string
	OutputTmp          string
	OutputLogs         string
	OutputBin          string
	OutputBinPath      string
	OutputBinToolPath  string
	OutputHostBin      string
	OutputHostBinTools string

	SrcDir   string // Source cmd directory
	ToolsDir string // Source tools directory
}

PathConfig represents the path configuration structure

var Paths *PathConfig

func NewPathConfig added in v0.0.16

func NewPathConfig(opts *PathOptions) (*PathConfig, error)

NewPathConfig creates a new path configuration with optional settings

func (*PathConfig) GetBinFullPath added in v0.0.16

func (p *PathConfig) GetBinFullPath(binName string) string

GetBinFullPath returns the full path for a binary file

func (*PathConfig) GetBinToolsFullPath added in v0.0.16

func (p *PathConfig) GetBinToolsFullPath(toolName string) string

GetToolFullPath returns the full path for a tool

type PathOptions added in v0.0.16

type PathOptions struct {
	RootDir   *string // Custom root directory, default is current working directory(./)
	OutputDir *string // Custom output directory name, default is "_output"
	ConfigDir *string // Custom config directory name, default is "config"

	SrcDir   *string // Custom cmd source directory name, default is "cmd"
	ToolsDir *string // Custom tools source directory name, default is "tools"
}

Jump to

Keyboard shortcuts

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