Documentation
¶
Index ¶
- Variables
- func GetRunScript(app string) string
- func IsValidApp(path string) bool
- func ProcessListenPorts(process *process.Process) []uint32
- type App
- type AppExit
- type AppID
- type AppInfo
- type AppInstallOpts
- type AppManager
- type AppProcess
- func (p *AppProcess) GetStatus() AppProcessStatus
- func (p *AppProcess) Process() *process.Process
- func (p *AppProcess) SetEnvs(envs map[string]string) *AppProcess
- func (p *AppProcess) SetID(id string) *AppProcess
- func (p *AppProcess) SetStderr(w io.Writer) *AppProcess
- func (p *AppProcess) SetStdout(w io.Writer) *AppProcess
- func (p *AppProcess) SetWorkingDir(path string) *AppProcess
- func (p *AppProcess) Start() error
- func (p *AppProcess) Stop() error
- func (p *AppProcess) Wait() (int, error)
- type AppProcessStatus
- type AppScheduler
- func (s *AppScheduler) GetApp(appId string) (*App, bool)
- func (s *AppScheduler) GetApps() []*App
- func (s *AppScheduler) Refresh() error
- func (s *AppScheduler) Start(ctx context.Context) error
- func (s *AppScheduler) StartApp(appId string) (*App, error)
- func (s *AppScheduler) Stop()
- func (s *AppScheduler) StopApp(appId string) (*App, error)
- type AppSource
- type ProcessStats
Constants ¶
This section is empty.
Variables ¶
var ( ErrAppAlreadyRunning = errors.New("app process already running") ErrAppNotRunning = errors.New("app process not running") )
var ( ErrAppNotFound = errors.New("app not found") ErrRefreshInProgress = errors.New("scheduler refresh in progress") )
var ErrGitNotAvailable = errors.New("git is not available on this system")
var (
ErrInvalidApp = errors.New("not a valid syftbox app")
)
Functions ¶
func GetRunScript ¶
func IsValidApp ¶
IsValidApp checks if a directory contains a valid app (has run.sh)
func ProcessListenPorts ¶
ProcessListenPorts returns a list of ports that the process is listening on
Types ¶
type App ¶
type App struct { *AppProcess // contains filtered or unexported fields }
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 (*AppInfo) RunScriptPath ¶ added in v0.7.0
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) 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) 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
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)