apps

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAppAlreadyRunning = errors.New("app process already running")
	ErrAppNotRunning     = errors.New("app process not running")
)
View Source
var (
	ErrAppNotFound       = errors.New("app not found")
	ErrRefreshInProgress = errors.New("scheduler refresh in progress")
)
View Source
var ErrGitNotAvailable = errors.New("git is not available on this system")
View Source
var (
	ErrInvalidApp = errors.New("not a valid syftbox app")
)

Functions

func GetRunScript

func GetRunScript(app string) string

func IsValidApp

func IsValidApp(path string) bool

IsValidApp checks if a directory contains a valid app (has run.sh)

func ProcessListenPorts

func ProcessListenPorts(process *process.Process) []uint32

ProcessListenPorts returns a list of ports that the process is listening on

Types

type App

type App struct {
	*AppProcess
	// contains filtered or unexported fields
}

func NewApp

func NewApp(info *AppInfo, configPath string) (*App, error)

func (*App) Info

func (a *App) Info() *AppInfo

func (*App) Start

func (a *App) Start() error

func (*App) Stop

func (a *App) Stop() error

type AppExit

type AppExit struct {
	Code  int
	Error error
}

type AppID

type AppID = string

type AppInfo

type AppInfo struct {
	ID          AppID     `json:"id"`
	Name        string    `json:"name"`
	Path        string    `json:"path"`
	Source      AppSource `json:"source"`
	SourceURI   string    `json:"sourceURI,omitempty"`
	Branch      string    `json:"branch,omitempty"`
	Tag         string    `json:"tag,omitempty"`
	Commit      string    `json:"commit,omitempty"`
	InstalledOn time.Time `json:"installedOn,omitempty"`
}

func (*AppInfo) LogFilePath added in v0.7.0

func (a *AppInfo) LogFilePath() string

func (*AppInfo) LogsDir added in v0.7.0

func (a *AppInfo) LogsDir() string

func (*AppInfo) RunScriptPath added in v0.7.0

func (a *AppInfo) RunScriptPath() string

type AppInstallOpts

type AppInstallOpts struct {
	URI    string // Local Path or Git URL of the app
	Branch string // Git branch to install
	Tag    string // Git tag to install
	Commit string // Git commit hash to install
	UseGit bool   // Use git to install
	Force  bool   // Force install
}

AppInstallOpts contains options for repository installation

type AppManager

type AppManager struct {
	AppsDir string // Directory where apps are stored
	DataDir string // Directory where internal data is stored
	// contains filtered or unexported fields
}

AppManager handles app installation, uninstallation, and listing operations

func NewManager

func NewManager(appDir string, internalDataDir string) *AppManager

NewManager creates a new Manager instance with the specified app directory

func (*AppManager) GetAppByID added in v0.7.0

func (a *AppManager) GetAppByID(appID string) (*AppInfo, error)

func (*AppManager) InstallApp

func (a *AppManager) InstallApp(ctx context.Context, opts AppInstallOpts) (*AppInfo, error)

func (*AppManager) ListApps

func (a *AppManager) ListApps() ([]*AppInfo, error)

func (*AppManager) UninstallApp

func (a *AppManager) UninstallApp(uri string) (string, error)

UninstallApp uninstalls an app from a given uri. The uri can be a local path or a remote url or app id

type AppProcess

type AppProcess struct {
	ID string // not PID!
	// contains filtered or unexported fields
}

AppProcess manages a subprocess and its children

func NewAppProcess

func NewAppProcess(name string, args ...string) *AppProcess

NewAppProcess creates a new AppProcess instance

func (*AppProcess) GetStatus

func (p *AppProcess) GetStatus() AppProcessStatus

func (*AppProcess) Process

func (p *AppProcess) Process() *process.Process

func (*AppProcess) SetEnvs

func (p *AppProcess) SetEnvs(envs map[string]string) *AppProcess

func (*AppProcess) SetID

func (p *AppProcess) SetID(id string) *AppProcess

func (*AppProcess) SetStderr

func (p *AppProcess) SetStderr(w io.Writer) *AppProcess

func (*AppProcess) SetStdout

func (p *AppProcess) SetStdout(w io.Writer) *AppProcess

func (*AppProcess) SetWorkingDir

func (p *AppProcess) SetWorkingDir(path string) *AppProcess

func (*AppProcess) Start

func (p *AppProcess) Start() error

Start starts the subprocess

func (*AppProcess) Stop

func (p *AppProcess) Stop() error

Stop terminates the process and all its children

func (*AppProcess) Wait

func (p *AppProcess) Wait() (int, error)

Wait blocks until the process exits and returns the exit code or error

type AppProcessStatus

type AppProcessStatus string
const (
	StatusNew     AppProcessStatus = "new"
	StatusRunning AppProcessStatus = "running"
	StatusStopped AppProcessStatus = "stopped"
)

type AppScheduler

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

func NewAppScheduler

func NewAppScheduler(mgr *AppManager, configPath string) *AppScheduler

func (*AppScheduler) GetApp

func (s *AppScheduler) GetApp(appId string) (*App, bool)

Get an app

func (*AppScheduler) GetApps

func (s *AppScheduler) GetApps() []*App

func (*AppScheduler) Refresh

func (s *AppScheduler) Refresh() error

func (*AppScheduler) Start

func (s *AppScheduler) Start(ctx context.Context) error

Start the scheduler

func (*AppScheduler) StartApp

func (s *AppScheduler) StartApp(appId string) (*App, error)

Start an app

func (*AppScheduler) Stop

func (s *AppScheduler) Stop()

Stop the scheduler

func (*AppScheduler) StopApp

func (s *AppScheduler) StopApp(appId string) (*App, error)

type AppSource

type AppSource = string
const (
	AppSourceGit      AppSource = "git"
	AppSourceLocalDir AppSource = "local"
)

type ProcessStats

type ProcessStats struct {
	// Process Name
	ProcessName string `json:"processName"`
	// Process ID
	PID int32 `json:"pid"`
	// Status of the process
	Status []string `json:"status"`
	// Command line arguments for this app's process
	Cmdline []string `json:"cmdline"`
	// Current working directory of this app's process
	CWD string `json:"cwd"`
	// Environment variables for this app's process
	Environ []string `json:"environ"`
	// Executable path of this app's process
	Exe string `json:"exe"`
	// List of groups this app is a member of
	Gids []uint32 `json:"gids"`
	// List of user IDs this app is a member of
	Uids []uint32 `json:"uids"`
	// Nice value of this app's process
	Nice int32 `json:"nice"`
	// Username of the user this app is running as
	Username string `json:"username"`
	// All connections this app is listening on
	Connections []net.ConnectionStat `json:"connections"`
	// Percentage of total CPU this app is using
	CPUPercent float64 `json:"cpuPercent"`
	// CPU times breakdown
	CPUTimes *cpu.TimesStat `json:"cpuTimes"`
	// Number of threads this app is using
	NumThreads int32 `json:"numThreads"`
	// Percentage of total RAM this app is using
	MemoryPercent float32 `json:"memoryPercent"`
	// Memory info
	MemoryInfo *process.MemoryInfoStat `json:"memoryInfo"`
	// How long the app has been running in milliseconds
	Uptime int64 `json:"uptime"`
	// Children processes
	Children []*ProcessStats `json:"children"`
}

func NewProcessStats

func NewProcessStats(p *process.Process) (*ProcessStats, error)

Jump to

Keyboard shortcuts

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