apps

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APPS_DIR            = "/usr/local/k8shell/apps"
	VERSION_CMD_TIMEOUT = 10 * time.Second
	APP_STOP_TIMEOUT    = 5 * time.Second
)

Variables

View Source
var ErrAppInvalidState = fmt.Errorf("not a valid app state")
View Source
var ErrAppNotFound = fmt.Errorf("app not found")
View Source
var ErrNoAppsConfigured = fmt.Errorf("no apps configured")

Functions

This section is empty.

Types

type AppManager

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

AppManager manages the lifecycle of applications defined in the configuration

func NewAppManager

func NewAppManager(apps map[string]*commonmodels.AppSpec, user *models.User, procWatcher *system.ProcessWatcher,
	testMode bool) (*AppManager, error)

NewAppManager creates a new AppManager instance

func (*AppManager) Apps

func (m *AppManager) Apps() map[string]*commonmodels.AppSpec

func (*AppManager) GetApp

func (m *AppManager) GetApp(name string) (*commonmodels.AppSpec, error)

GetApp retrieves the app specification by name.

func (*AppManager) GetLastLog

func (m *AppManager) GetLastLog(name string, logType string) (string, error)

GetLastLog returns the contents of the most recent log of the given type for the app. If no log exists, it returns empty string and no error.

func (*AppManager) GetLastLogPath

func (m *AppManager) GetLastLogPath(name string, logType string) (string, error)

GetLastLogPath returns the path of the most recent log for the app of the given type. If no log exists, it returns an empty string and no error.

func (*AppManager) GetSupervisor

func (m *AppManager) GetSupervisor(name string) (*AppSupervisor, bool)

GetSupervisor returns the supervisor for the given app, if it exists.

func (*AppManager) InstallAndStart

func (m *AppManager) InstallAndStart(ctx context.Context, name string) error

InstallAndStart installs the app if needed and then ensures it is running.

func (*AppManager) InstallAsync

func (m *AppManager) InstallAsync(ctx context.Context, name string, force bool) error

InstallAsync starts installation in the background. If an install for this app is already running, it returns an error.

func (*AppManager) IsInstalling

func (m *AppManager) IsInstalling(name string) bool

IsInstalling reports whether an install is currently running for the app.

func (*AppManager) IsRunning

func (m *AppManager) IsRunning(name string) bool

IsRunning reports whether the app is currently supervised and has a running PID.

func (*AppManager) ListAppStatus

func (m *AppManager) ListAppStatus(ctx context.Context) ([]k8shelld.AppStatus, error)

ListAppStatus returns app status including port, PID and running time, without internal state.

func (*AppManager) OpenLogFile

func (m *AppManager) OpenLogFile(name string, logType string) (*os.File, string, error)

GetLogFilePath returns a new log file path for the app of the given type.

func (*AppManager) Start

func (m *AppManager) Start(ctx context.Context, name string) error

Start starts a supervisor for the given app if not already running. The supervisor will keep the app running according to its RestartPolicy.

func (*AppManager) Stop

func (m *AppManager) Stop(ctx context.Context, name string) error

Stop asks the supervisor to stop managing the app and kills the process if running.

type AppSupervisor

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

supervisorState holds the state for a supervisor

func NewAppSupervisor

func NewAppSupervisor(manager *AppManager, app *commonmodels.AppSpec) *AppSupervisor

func (*AppSupervisor) PID

func (s *AppSupervisor) PID() int

func (*AppSupervisor) RequestStop

func (s *AppSupervisor) RequestStop()

func (*AppSupervisor) Restarts

func (s *AppSupervisor) Restarts() int

Jump to

Keyboard shortcuts

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